@thanh01.pmt/domain-kit 0.4.0 → 0.5.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/LICENSE +21 -0
- package/dist/{chunk-PKUEOSZ3.mjs → chunk-E4GCCWJO.mjs} +11 -2
- package/dist/chunk-E4GCCWJO.mjs.map +1 -0
- package/dist/{chunk-LZQLLAYP.mjs → chunk-G7HLFMD2.mjs} +5 -5
- package/dist/{chunk-LZQLLAYP.mjs.map → chunk-G7HLFMD2.mjs.map} +1 -1
- package/dist/{chunk-QJF4QCBJ.mjs → chunk-TWKIVUTQ.mjs} +8 -3
- package/dist/chunk-TWKIVUTQ.mjs.map +1 -0
- package/dist/{chunk-HILSUZOF.mjs → chunk-TYXSJUQU.mjs} +99 -8
- package/dist/chunk-TYXSJUQU.mjs.map +1 -0
- package/dist/curriculumFeedEmitter-T7NUBLAM.mjs +4 -0
- package/dist/{curriculumFeedEmitter-6IK6PFDH.mjs.map → curriculumFeedEmitter-T7NUBLAM.mjs.map} +1 -1
- package/dist/{curriculumFeedSchema-B66H3gEV.d.ts → curriculumFeedSchema-DUFwFyr2.d.cts} +56 -0
- package/dist/{curriculumFeedSchema-B66H3gEV.d.cts → curriculumFeedSchema-DUFwFyr2.d.ts} +56 -0
- package/dist/feed/index.cjs +14 -0
- package/dist/feed/index.cjs.map +1 -1
- package/dist/feed/index.d.cts +1 -1
- package/dist/feed/index.d.ts +1 -1
- package/dist/feed/index.mjs +2 -2
- package/dist/graph/index.cjs +97 -6
- package/dist/graph/index.cjs.map +1 -1
- package/dist/graph/index.mjs +1 -1
- package/dist/index.cjs +111 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +4 -4
- package/dist/pipeline/index.cjs +111 -6
- package/dist/pipeline/index.cjs.map +1 -1
- package/dist/pipeline/index.d.cts +1 -1
- package/dist/pipeline/index.d.ts +1 -1
- package/dist/pipeline/index.mjs +4 -4
- package/dist/schemas/index.cjs +9 -0
- package/dist/schemas/index.cjs.map +1 -1
- package/dist/schemas/index.d.cts +1 -1
- package/dist/schemas/index.d.ts +1 -1
- package/dist/schemas/index.mjs +1 -1
- package/package.json +9 -10
- package/dist/chunk-HILSUZOF.mjs.map +0 -1
- package/dist/chunk-PKUEOSZ3.mjs.map +0 -1
- package/dist/chunk-QJF4QCBJ.mjs.map +0 -1
- package/dist/curriculumFeedEmitter-6IK6PFDH.mjs +0 -4
package/dist/graph/index.cjs
CHANGED
|
@@ -1963,7 +1963,42 @@ async function generateKnowledgeGraph(options) {
|
|
|
1963
1963
|
const structuredTopicsGuide = parsedSyllabus && parsedSyllabus.allTopics.length > 0 ? `
|
|
1964
1964
|
STRUCTURED SYLLABUS TOPICS (Every topic MUST map to at least one concept to ensure 100% syllabus coverage):
|
|
1965
1965
|
` + parsedSyllabus.allTopics.map((t) => `- [${t.unitTitle}] ${t.id}: ${t.title} (Keywords: ${t.keywords.join(", ")})`).join("\n") + "\n" : "";
|
|
1966
|
-
const systemPrompt =
|
|
1966
|
+
const systemPrompt = `You are an expert curriculum designer. Decompose the given subject into a structured knowledge graph with concepts, prerequisites, and problem types.
|
|
1967
|
+
|
|
1968
|
+
CRITICAL RULES:
|
|
1969
|
+
1. Each concept MUST have the three depth layers, authored against this CONTRACT:
|
|
1970
|
+
- ulo (WHAT + WHY): bound to the CONCEPT's intrinsic NATURE. It explains what the
|
|
1971
|
+
concept is and why it exists \u2014 the problem it solves in principle. It must be
|
|
1972
|
+
TECHNOLOGY-AGNOSTIC: never name a concrete library, API, function, file format,
|
|
1973
|
+
tool or language feature. Typical assessment level: Remember / Understand.
|
|
1974
|
+
- cio (HOW): the MECHANISM \u2014 how the concept works and solves that problem, step
|
|
1975
|
+
by step. Still bound to the concept's nature: more concrete than the ULO, but
|
|
1976
|
+
NOT tied to one specific technology (no concrete API names). CIO capability is
|
|
1977
|
+
assessed INDIRECTLY, through completing contextual work, not in isolation.
|
|
1978
|
+
- sio (IMPLEMENTATION): an array of 2-4 items. EVERY item MUST reference concrete
|
|
1979
|
+
KEYWORDS/technologies (a real API, function, module, file, or named pattern) and
|
|
1980
|
+
describe a completable, context-specific implementation task. Application,
|
|
1981
|
+
Analysis and Creation skills are assessed INDIRECTLY through completing these
|
|
1982
|
+
items. There is NO fixed Bloom ceiling for a layer \u2014 but concreteness MUST
|
|
1983
|
+
strictly increase: SIO more technology-bound than CIO, CIO more concrete than ULO.
|
|
1984
|
+
- prerequisites: concept IDs that must be learned first (MUST NOT create cycles)
|
|
1985
|
+
- problem_types: 2-4 problem types with bloom_level and difficulty. Remember and
|
|
1986
|
+
Understand problem types test the ULO/CIO directly; Apply-and-above types are
|
|
1987
|
+
proxies for SIO completion in context.
|
|
1988
|
+
- techniques: methods, formulas, tools
|
|
1989
|
+
2. Prerequisite chains MUST be acyclic (no concept can depend on itself or create a loop)
|
|
1990
|
+
3. Concepts should be ordered by prerequisite dependency (topological sort)
|
|
1991
|
+
4. Problem types should range from Remember to Apply (not all at same level)
|
|
1992
|
+
5. Group concepts into categories (chapters/sections)
|
|
1993
|
+
6. ALL text in ENGLISH (even if input is Vietnamese)
|
|
1994
|
+
7. NEVER invent concepts not present in the syllabus
|
|
1995
|
+
8. KEYWORDS: Each concept MUST include 5-10 domain-specific keywords that:
|
|
1996
|
+
- Are concrete terms a student encounters when studying THIS concept
|
|
1997
|
+
- Include at least 2 technology-specific terms (APIs, functions, types, tools)
|
|
1998
|
+
- Are DISTINCT from keywords of other concepts (minimal overlap)
|
|
1999
|
+
- NEVER generic English words (e.g. "view", "data", "code" are TOO generic)
|
|
2000
|
+
- Example for "SwiftUI Layout": ["VStack", "HStack", "ZStack", ".padding()", ".frame()", "alignment", "Spacer", "LazyVGrid"]
|
|
2001
|
+
9. Return JSON matching the KnowledgeGraphSchema`;
|
|
1967
2002
|
const userPrompt = `Subject: ${subject}
|
|
1968
2003
|
${description ? `Description: ${description}` : ""}
|
|
1969
2004
|
${structuredTopicsGuide}${truncatedSyllabus ? `Syllabus:
|
|
@@ -1984,8 +2019,9 @@ Return JSON:
|
|
|
1984
2019
|
{
|
|
1985
2020
|
"id": "C1",
|
|
1986
2021
|
"name": "Concept name",
|
|
1987
|
-
"description": "
|
|
2022
|
+
"description": "2-3 sentence description: what this concept covers, why a learner encounters it, and what mastering it enables. Must be specific enough that a student reading only this description understands the concept's scope.",
|
|
1988
2023
|
"category": "category_id",
|
|
2024
|
+
"keywords": ["specific_term_1", "concrete_api_2", "method_call_3", "tool_or_type_4", "syntax_keyword_5", "concept_term_6"],
|
|
1989
2025
|
"ulo": "WHAT + WHY in technology-agnostic language: what the concept is and the problem it exists to solve. No library/API/tool names.",
|
|
1990
2026
|
"cio": "HOW the mechanism works, still technology-agnostic but more concrete than the ULO.",
|
|
1991
2027
|
"sio": ["Concrete task naming a REAL API/function/module/file from the target technology, completable end to end", "Another technology-bound task using a different concrete keyword"],
|
|
@@ -2026,18 +2062,23 @@ Return JSON:
|
|
|
2026
2062
|
log("STEP_2", "Validating and cleaning knowledge graph...");
|
|
2027
2063
|
const concepts = result.concepts || [];
|
|
2028
2064
|
const categories = result.categories || [];
|
|
2065
|
+
for (const c of concepts) {
|
|
2066
|
+
if ((c.description || "").length < 50) {
|
|
2067
|
+
warnings.push("Concept " + c.id + ": description too short (" + (c.description || "").length + " chars) \u2014 may produce shallow KX narratives");
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2029
2070
|
{
|
|
2030
2071
|
const STOP = /* @__PURE__ */ new Set(["and", "the", "for", "with", "from", "that", "this", "into", "when", "while", "using", "their", "your", "each", "how", "why", "what", "between", "through", "about"]);
|
|
2031
2072
|
const tokensFrom = (text) => text.toLowerCase().replace(/[^a-z0-9\s-]/g, " ").split(/\s+/).filter((w) => w.length >= 4 && !STOP.has(w));
|
|
2032
2073
|
for (const c of concepts) {
|
|
2033
2074
|
const existing = (c.keywords || []).map((k) => String(k).trim()).filter(Boolean);
|
|
2034
2075
|
if (existing.length === 0) {
|
|
2035
|
-
const derived = [.../* @__PURE__ */ new Set([...tokensFrom(c.name), ...tokensFrom(c.description || "")])].slice(0,
|
|
2076
|
+
const derived = [.../* @__PURE__ */ new Set([...tokensFrom(c.name), ...tokensFrom(c.description || "")])].slice(0, 8);
|
|
2036
2077
|
if (derived.length === 0) {
|
|
2037
2078
|
throw new Error("Concept " + c.id + " (" + c.name + ") has no keywords and none could be derived from name/description \u2014 fail-closed");
|
|
2038
2079
|
}
|
|
2039
2080
|
c.keywords = derived;
|
|
2040
|
-
warnings.push("Concept " + c.id + ": empty keyword set - derived " + derived.join(", ") + " from name/description");
|
|
2081
|
+
warnings.push("Concept " + c.id + ": empty keyword set - derived " + derived.join(", ") + " from name/description (WARNING: LLM returned no keywords)");
|
|
2041
2082
|
} else {
|
|
2042
2083
|
c.keywords = existing;
|
|
2043
2084
|
}
|
|
@@ -2162,6 +2203,52 @@ Return JSON:
|
|
|
2162
2203
|
}
|
|
2163
2204
|
log("STEP_5", "Depth layers authored: " + concepts.length + " concepts, audit " + lo.audits.filter((a) => a.passed).length + "/" + concepts.length + " passed");
|
|
2164
2205
|
}
|
|
2206
|
+
{
|
|
2207
|
+
for (const concept of concepts) {
|
|
2208
|
+
const sioText = (concept.sio || []).join(" ");
|
|
2209
|
+
const techTokens = [];
|
|
2210
|
+
let m;
|
|
2211
|
+
const techTokenRe = /`([^`]+)`/g;
|
|
2212
|
+
while ((m = techTokenRe.exec(sioText)) !== null) {
|
|
2213
|
+
if (m[1].length >= 3 && m[1].length <= 40) techTokens.push(m[1]);
|
|
2214
|
+
}
|
|
2215
|
+
const annotationRe = /(?:^|[\s(])(@[A-Za-z]\w*)/g;
|
|
2216
|
+
while ((m = annotationRe.exec(sioText)) !== null) techTokens.push(m[1]);
|
|
2217
|
+
const dotRe = /\b\w+\.\w+\(/g;
|
|
2218
|
+
while ((m = dotRe.exec(sioText)) !== null) techTokens.push(m[0].replace("(", ""));
|
|
2219
|
+
const modifierRe = /(?:^|[\s(])(\.[a-z]\w*)\b/g;
|
|
2220
|
+
while ((m = modifierRe.exec(sioText)) !== null) techTokens.push(m[1]);
|
|
2221
|
+
const camelRe = /\b[a-z]+[A-Z][A-Za-z]+\b/g;
|
|
2222
|
+
while ((m = camelRe.exec(sioText)) !== null) techTokens.push(m[0]);
|
|
2223
|
+
const existing = new Set((concept.keywords || []).map((k) => k.toLowerCase()));
|
|
2224
|
+
const newTokens = [...new Set(techTokens)].filter((t) => !existing.has(t.toLowerCase())).slice(0, 8);
|
|
2225
|
+
if (newTokens.length > 0) {
|
|
2226
|
+
concept.keywords = [...concept.keywords || [], ...newTokens];
|
|
2227
|
+
warnings.push("Concept " + concept.id + ": enriched keywords with " + newTokens.length + " SIO-derived tokens");
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
log("STEP_5b", "SIO-keyword enrichment complete");
|
|
2231
|
+
}
|
|
2232
|
+
{
|
|
2233
|
+
for (const concept of concepts) {
|
|
2234
|
+
const sioCount = (concept.sio || []).length;
|
|
2235
|
+
const ptCount = (concept.problem_types || []).length;
|
|
2236
|
+
const prereqCount = (concept.prerequisites || []).length;
|
|
2237
|
+
const hasHighBloom = (concept.problem_types || []).some(
|
|
2238
|
+
(pt) => ["Analyze", "Evaluate", "Create"].includes(pt.bloom_level || "")
|
|
2239
|
+
);
|
|
2240
|
+
const score = Math.min(1, sioCount * 0.2 + ptCount * 0.15 + prereqCount * 0.15 + (hasHighBloom ? 0.2 : 0));
|
|
2241
|
+
const calibrated = Math.round(15 + score * 45);
|
|
2242
|
+
const llmEstimate = concept.estimated_minutes || 30;
|
|
2243
|
+
if (llmEstimate === 30 || Math.abs(calibrated - llmEstimate) / llmEstimate > 0.5) {
|
|
2244
|
+
concept.estimated_minutes = calibrated;
|
|
2245
|
+
if (llmEstimate !== calibrated) {
|
|
2246
|
+
warnings.push("Concept " + concept.id + ": minutes calibrated " + llmEstimate + "m \u2192 " + calibrated + "m (score=" + score.toFixed(2) + ")");
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
log("STEP_5c", "Minute calibration complete");
|
|
2251
|
+
}
|
|
2165
2252
|
for (const step of learningPath) {
|
|
2166
2253
|
if (!conceptIds.has(step.concept_id)) {
|
|
2167
2254
|
warnings.push(`Learning path references non-existent concept ${step.concept_id}`);
|
|
@@ -2427,8 +2514,12 @@ async function decomposePhases(args) {
|
|
|
2427
2514
|
const linkList = links.map(
|
|
2428
2515
|
(l) => "- " + l.feature_id + " -> " + l.concept_id + " (" + l.depth + ")"
|
|
2429
2516
|
).join("\n") || "(none)";
|
|
2430
|
-
const systemPrompt = 'You decompose a software project build into PROGRESSIVE COMPLETION PHASES for learning purposes.\n\nA phase is NOT a feature and NOT a milestone list: it is a cross-feature slice of the\nproduct whose completion yields a DEMONSTRABLY more complete product. Build up gradually:\nthe product grows feature by feature across phases, and each phase adds its features to\nwhat previous phases already built.\n\nRULES:\n1. Every feature must be assigned to EXACTLY ONE phase (no feature reused, none skipped).\n2. Phases are ordered; later phases depend on earlier ones and yield a more complete product.\n3. product_completion describes concretely what the product can DO once the phase is done.\n4. introduces lists which concepts the phase must teach BEFORE its feature work starts:\n - aspect new: first time the concept appears in the course\n - aspect advanced: a concept introduced in an EARLIER phase, revisited here at a\n higher depth (an advanced aspect of the same concept, e.g. validation rules on top\n of basic data modeling). Use the note field to say which aspect.\n - aspect preview: a light awareness pass ("know it exists", ULO depth only, ~5 min)\n placed in an EARLIER phase when its feature work needs the vocabulary before the\n full teach. The anchor phase still owns the full new introduction.\n5. A concept MUST be introduced (new) no later than the first phase that consumes it.\n6. A concept must not be introduced before its own prerequisites are introduced.\n7. Typically 3-6 phases for a small project; keep phases balanced.\n8. Phase 1 usually covers project setup/foundation features plus the first minimal slice.\
|
|
2431
|
-
const
|
|
2517
|
+
const systemPrompt = 'You decompose a software project build into PROGRESSIVE COMPLETION PHASES for learning purposes.\n\nA phase is NOT a feature and NOT a milestone list: it is a cross-feature slice of the\nproduct whose completion yields a DEMONSTRABLY more complete product. Build up gradually:\nthe product grows feature by feature across phases, and each phase adds its features to\nwhat previous phases already built.\n\nRULES:\n1. Every feature must be assigned to EXACTLY ONE phase (no feature reused, none skipped).\n2. Phases are ordered; later phases depend on earlier ones and yield a more complete product.\n3. product_completion describes concretely what the product can DO once the phase is done.\n4. introduces lists which concepts the phase must teach BEFORE its feature work starts:\n - aspect new: first time the concept appears in the course\n - aspect advanced: a concept introduced in an EARLIER phase, revisited here at a\n higher depth (an advanced aspect of the same concept, e.g. validation rules on top\n of basic data modeling). Use the note field to say which aspect.\n - aspect preview: a light awareness pass ("know it exists", ULO depth only, ~5 min)\n placed in an EARLIER phase when its feature work needs the vocabulary before the\n full teach. The anchor phase still owns the full new introduction.\n5. A concept MUST be introduced (new) no later than the first phase that consumes it.\n6. A concept must not be introduced before its own prerequisites are introduced.\n7. Typically 3-6 phases for a small project; keep phases balanced.\n8. MINUTE BALANCE: Each phase should contain approximately 120-240 total minutes of\n concept + feature work (about 3-5 sessions of 90 minutes each). If a phase\n would contain < 60 minutes (too thin) or > 400 minutes (too heavy), rebalance.\n9. Phase 1 usually covers project setup/foundation features plus the first minimal slice.\n10. Return JSON only.';
|
|
2518
|
+
const totalFeatureMinutes = features.reduce((s, f) => s + (f.steps || []).reduce((ss, st) => ss + (st.effort?.estimated_minutes || 15), 0), 0);
|
|
2519
|
+
const totalConceptMinutes = concepts.reduce((s, c) => s + (c.estimated_minutes || 30), 0);
|
|
2520
|
+
const totalMinutes = totalFeatureMinutes + totalConceptMinutes;
|
|
2521
|
+
const targetPhaseCount = Math.max(3, Math.round(totalMinutes / 180));
|
|
2522
|
+
const baseUserPrompt = "FEATURES:\n" + featureList + "\n\nCONCEPTS:\n" + conceptList + "\n\nFEATURE-CONCEPT LINKS:\n" + linkList + "\n\nTOTAL MINUTES: ~" + totalMinutes + "m (" + totalFeatureMinutes + "m features + " + totalConceptMinutes + "m concepts)\nTARGET: ~" + targetPhaseCount + " phases of ~180m each\n\nReturn JSON with a phases array. Each phase: { id: PH1, name, product_completion, feature_ids: [F0, F1], introduces: [{ concept_id: C1, aspect: new or advanced, note }] }.\n";
|
|
2432
2523
|
const MAX_DECOMPOSE_ATTEMPTS = 3;
|
|
2433
2524
|
let auditErrors = [];
|
|
2434
2525
|
let phases = [];
|