@thanh01.pmt/research-kit 1.2.4 → 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.
Files changed (74) hide show
  1. package/dist/academic/index.cjs +122 -0
  2. package/dist/academic/index.cjs.map +1 -1
  3. package/dist/academic/index.d.cts +27 -4
  4. package/dist/academic/index.d.ts +27 -4
  5. package/dist/academic/index.js +2 -1
  6. package/dist/agent/index.cjs +4277 -0
  7. package/dist/agent/index.cjs.map +1 -0
  8. package/dist/agent/index.d.cts +10 -0
  9. package/dist/agent/index.d.ts +10 -0
  10. package/dist/agent/index.js +10 -0
  11. package/dist/agent/index.js.map +1 -0
  12. package/dist/{catalogBuilder-B4eiLS_S.d.cts → catalogBuilder-BBCa9jqI.d.cts} +2 -2
  13. package/dist/{catalogBuilder-BNB_gaWP.d.ts → catalogBuilder-D-UiM37y.d.ts} +2 -2
  14. package/dist/chunk-2GBXVPOQ.js +3 -0
  15. package/dist/{chunk-J3VCGH7Z.js.map → chunk-2GBXVPOQ.js.map} +1 -1
  16. package/dist/chunk-2RMBLKP5.js +581 -0
  17. package/dist/chunk-2RMBLKP5.js.map +1 -0
  18. package/dist/{chunk-2XIEWCUE.js → chunk-32B5PVTQ.js} +2 -2
  19. package/dist/{chunk-2XIEWCUE.js.map → chunk-32B5PVTQ.js.map} +1 -1
  20. package/dist/{chunk-YICMTZS5.js → chunk-4O3FXMXO.js} +171 -3
  21. package/dist/chunk-4O3FXMXO.js.map +1 -0
  22. package/dist/chunk-LDCZ33AC.js +3 -0
  23. package/dist/chunk-LDCZ33AC.js.map +1 -0
  24. package/dist/{chunk-GK5KI5PB.js → chunk-MFRQ2VJZ.js} +63 -44
  25. package/dist/chunk-MFRQ2VJZ.js.map +1 -0
  26. package/dist/chunk-RAMDHDRJ.js +1931 -0
  27. package/dist/chunk-RAMDHDRJ.js.map +1 -0
  28. package/dist/{chunk-SAHBBO3U.js → chunk-RYLZYZRF.js} +4 -580
  29. package/dist/chunk-RYLZYZRF.js.map +1 -0
  30. package/dist/chunk-SHBDLP64.js +125 -0
  31. package/dist/chunk-SHBDLP64.js.map +1 -0
  32. package/dist/chunk-TYQEC24G.js +3 -0
  33. package/dist/chunk-TYQEC24G.js.map +1 -0
  34. package/dist/{chunk-KXJDQBSJ.js → chunk-UHKDJZNL.js} +11 -4
  35. package/dist/chunk-UHKDJZNL.js.map +1 -0
  36. package/dist/config/index.d.cts +1 -1
  37. package/dist/config/index.d.ts +1 -1
  38. package/dist/evidence/index.cjs +9 -2
  39. package/dist/evidence/index.cjs.map +1 -1
  40. package/dist/evidence/index.d.cts +2 -2
  41. package/dist/evidence/index.d.ts +2 -2
  42. package/dist/evidence/index.js +3 -2
  43. package/dist/harvester/index.cjs +168 -1
  44. package/dist/harvester/index.cjs.map +1 -1
  45. package/dist/harvester/index.d.cts +5 -161
  46. package/dist/harvester/index.d.ts +5 -161
  47. package/dist/harvester/index.js +4 -2
  48. package/dist/index-CGa7lf3L.d.ts +764 -0
  49. package/dist/{index-9rDiFuR4.d.cts → index-CxoD81QN.d.cts} +1 -1
  50. package/dist/{index-9rDiFuR4.d.ts → index-CxoD81QN.d.ts} +1 -1
  51. package/dist/index-DrjfrbGw.d.cts +764 -0
  52. package/dist/index.cjs +2411 -144
  53. package/dist/index.cjs.map +1 -1
  54. package/dist/index.d.cts +11 -174
  55. package/dist/index.d.ts +11 -174
  56. package/dist/index.js +34 -12
  57. package/dist/index.js.map +1 -1
  58. package/dist/{literatureReview-DOzgm9Q2.d.ts → literatureReview-Bn2iEGRO.d.ts} +1 -1
  59. package/dist/{literatureReview-BwidpYJo.d.cts → literatureReview-Bvlqk4DB.d.cts} +1 -1
  60. package/dist/pipeline/index.cjs +68 -43
  61. package/dist/pipeline/index.cjs.map +1 -1
  62. package/dist/pipeline/index.d.cts +5 -4
  63. package/dist/pipeline/index.d.ts +5 -4
  64. package/dist/pipeline/index.js +4 -3
  65. package/dist/socialPulseHarvester-CN4MwrpY.d.cts +204 -0
  66. package/dist/socialPulseHarvester-IbdT3zD1.d.ts +204 -0
  67. package/dist/{webScraper-CAQjE46m.d.cts → webScraper-BVvNW4yj.d.cts} +1 -1
  68. package/dist/{webScraper-CXIpvyA6.d.ts → webScraper-C9pB5Rgd.d.ts} +1 -1
  69. package/package.json +6 -1
  70. package/dist/chunk-GK5KI5PB.js.map +0 -1
  71. package/dist/chunk-J3VCGH7Z.js +0 -3
  72. package/dist/chunk-KXJDQBSJ.js.map +0 -1
  73. package/dist/chunk-SAHBBO3U.js.map +0 -1
  74. package/dist/chunk-YICMTZS5.js.map +0 -1
@@ -605,7 +605,7 @@ var MultiSourceSearchEngine = class {
605
605
  if (adapter && (!preferred || preferred === "custom")) {
606
606
  try {
607
607
  const customResults = await adapter.search(query, { limit, domainFilter: options.domainFilter });
608
- if (Array.isArray(customResults) && customResults.length > 0) {
608
+ if (Array.isArray(customResults)) {
609
609
  return customResults.map((r) => ({
610
610
  title: r.title,
611
611
  url: r.url,
@@ -1969,6 +1969,13 @@ Return ONLY a valid JSON array of 6 to 12 atomic pedagogical concepts ordered fr
1969
1969
  function tokenizeBilingualKeywords(text) {
1970
1970
  return text.normalize("NFC").toLowerCase().replace(/[.,;:!?()[\]{}"“”‘’/\\|`*_~#-]+/g, " ").split(/\s+/).filter((w) => w.length >= 2 && !/^(and|the|for|with|from|into|của|trong|được|những|các|cho|với|khi|và|hoặc|để|từ|đến|về)$/.test(w));
1971
1971
  }
1972
+ function keywordMatchesText(keyword, lowerText) {
1973
+ if (keyword.length <= 3) {
1974
+ const escaped = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1975
+ return new RegExp(`(?:^|[^a-z0-9\\u00C0-\\u1EF9])${escaped}(?:$|[^a-z0-9\\u00C0-\\u1EF9])`, "i").test(lowerText);
1976
+ }
1977
+ return lowerText.includes(keyword);
1978
+ }
1972
1979
  function extractTopSentences(markdown, targetTopic, maxSentences = 3) {
1973
1980
  const keywords = tokenizeBilingualKeywords(targetTopic);
1974
1981
  const withoutCode = markdown.replace(/```[\s\S]*?```/g, " ");
@@ -1981,7 +1988,7 @@ function extractTopSentences(markdown, targetTopic, maxSentences = 3) {
1981
1988
  if (rawSentences.length === 0) return [];
1982
1989
  const scored = rawSentences.map((sentence, idx) => {
1983
1990
  const lower = sentence.normalize("NFC").toLowerCase();
1984
- const matchedCount = keywords.filter((k) => lower.includes(k)).length;
1991
+ const matchedCount = keywords.filter((k) => keywordMatchesText(k, lower)).length;
1985
1992
  const positionBonus = idx < 8 ? 1.5 : idx < 20 ? 0.5 : 0;
1986
1993
  const technicalBonus = /(`[^`]+`|\b(?:api|function|class|actor|async|sensor|pin|loop|state|biến|hàm|cảm biến|vòng lặp|mạch)\b)/i.test(
1987
1994
  sentence
@@ -2002,7 +2009,7 @@ var EvidenceScorer = class {
2002
2009
  let noiseScore = 2;
2003
2010
  const lowerContent = doc.markdownContent.normalize("NFC").toLowerCase();
2004
2011
  const targetKeywords = tokenizeBilingualKeywords(targetTopic);
2005
- const keywordMatches = targetKeywords.filter((k) => lowerContent.includes(k)).length;
2012
+ const keywordMatches = targetKeywords.filter((k) => keywordMatchesText(k, lowerContent)).length;
2006
2013
  const matchRatio = targetKeywords.length > 0 ? keywordMatches / targetKeywords.length : 1;
2007
2014
  if (matchRatio >= 0.75) depthScore += 3;
2008
2015
  else if (matchRatio >= 0.4) depthScore += 2;
@@ -2821,33 +2828,17 @@ var TechnicalGroundingEngine = class {
2821
2828
  preservedKeyExcerpts.push(...s.keyExcerpts);
2822
2829
  }
2823
2830
  }
2824
- const defaultExemplars = [
2825
- {
2826
- title: scrapedSnippets[0]?.title || `${topic} Hands-on Foundation Project`,
2827
- description: scrapedSnippets[0]?.excerpt ? scrapedSnippets[0].excerpt.slice(0, 220) : `Verified practical implementation integrating ${hardware || "core principles"} and ${software || "standard development tools"}.`,
2828
- targetAudience: `Students aged ${ageBand[0]}-${ageBand[1]}`,
2829
- sourceUrl: scrapedSnippets[0]?.url,
2830
- hardwareRequirements: hardware ? [hardware] : void 0,
2831
- softwareRequirements: software ? [software] : void 0
2832
- }
2833
- ];
2834
- const defaultBottlenecks = domain === "hardware" || Boolean(hardware) ? [
2835
- "Power supply decoupling and current surge when powering sensors or actuators.",
2836
- "Logic level shifting and hardware pin mapping conflicts."
2837
- ] : domain === "academic" ? [
2838
- "Cognitive load pacing and abstract concept grounding with physical analogies."
2839
- ] : [
2840
- "SDK/runtime version compatibility and local environment dependencies.",
2841
- "Syntax confusion between asynchronous event handling and blocking calls."
2842
- ];
2831
+ const defaultExemplars = [];
2832
+ const defaultBottlenecks = [];
2843
2833
  let factsheet = {
2844
2834
  topic,
2845
2835
  domain,
2836
+ evidenceBacked: false,
2846
2837
  compatibilityMatrix: {
2847
2838
  hardwarePlatform: hardware || void 0,
2848
2839
  softwareEnv: software || void 0,
2849
2840
  verifiedCompatible: true,
2850
- notes: hardware || software ? [`Targeting ${hardware || "General Platform"} with ${software || "Standard SDK"}.`] : [`Baseline technical verification for ${topic}.`]
2841
+ notes: []
2851
2842
  },
2852
2843
  ageFeasibility: {
2853
2844
  recommendedMinAge: ageBand[0],
@@ -2857,7 +2848,7 @@ var TechnicalGroundingEngine = class {
2857
2848
  },
2858
2849
  exemplarProjects: defaultExemplars,
2859
2850
  technicalBottlenecks: defaultBottlenecks,
2860
- groundingSources: scrapedSnippets.map((s) => ({ title: s.title, url: s.url })),
2851
+ groundingSources: scrapedSnippets.filter((s) => Boolean(s.url)).map((s) => ({ title: s.title, url: s.url })),
2861
2852
  markdownReport: "",
2862
2853
  codeSnippets: preservedCodeSnippets.slice(0, 4),
2863
2854
  pinoutTables: preservedTables.slice(0, 4),
@@ -2865,9 +2856,10 @@ var TechnicalGroundingEngine = class {
2865
2856
  };
2866
2857
  if (llm && scrapedSnippets.length > 0) {
2867
2858
  try {
2859
+ const roleByDomain = domain === "hardware" ? "Hardware & Embedded Systems Curriculum Specialist" : domain === "software" ? "Software & Technology Curriculum Specialist" : "Applied Subject Matter & Curriculum Specialist";
2868
2860
  const prompt = [
2869
- `You are a Lead STEM Curriculum Engineer. Analyze these research excerpts for topic: "${topic}".`,
2870
- `Hardware: ${hardware || "N/A"}, Software/Env: ${software || "N/A"}, Student Age Band: ${ageBand[0]}-${ageBand[1]} years old.`,
2861
+ `You are a ${roleByDomain}. Analyze these verified research excerpts for topic: "${topic}".`,
2862
+ `Domain: ${domain}, Hardware: ${hardware || "N/A"}, Software/Env: ${software || "N/A"}, Student Age Band: ${ageBand[0]}-${ageBand[1]} years old.`,
2871
2863
  `
2872
2864
  Harvested Sources:
2873
2865
  ${scrapedSnippets.map((s, i) => {
@@ -2884,7 +2876,7 @@ ${c.code}
2884
2876
  return parts.join("\n");
2885
2877
  }).join("\n\n")}`,
2886
2878
  `
2887
- Synthesize a strictly valid JSON object with:`,
2879
+ Synthesize a strictly valid JSON object based ONLY on the evidence above. If no evidence exists for a field, leave it as an empty array [] without inventing facts:`,
2888
2880
  `{`,
2889
2881
  ` "compatibilityVerdict": boolean,`,
2890
2882
  ` "compatibilityNotes": string[],`,
@@ -2919,10 +2911,28 @@ Synthesize a strictly valid JSON object with:`,
2919
2911
  }));
2920
2912
  }
2921
2913
  if (Array.isArray(parsed.technicalBottlenecks)) factsheet.technicalBottlenecks = parsed.technicalBottlenecks.map(String);
2914
+ if (factsheet.exemplarProjects.length > 0 || factsheet.technicalBottlenecks.length > 0) {
2915
+ factsheet.evidenceBacked = true;
2916
+ }
2922
2917
  }
2923
2918
  } catch (err) {
2924
2919
  console.warn("[TechnicalGroundingEngine] LLM synthesis error:", err?.message || err);
2925
2920
  }
2921
+ } else if (scrapedSnippets.length > 0 && scrapedSnippets[0]?.excerpt?.trim()) {
2922
+ const first = scrapedSnippets[0];
2923
+ if (first.title || first.excerpt) {
2924
+ factsheet.exemplarProjects = [
2925
+ {
2926
+ title: first.title || `${topic} Hands-on Foundation Project`,
2927
+ description: first.excerpt.slice(0, 220),
2928
+ targetAudience: `Students aged ${ageBand[0]}-${ageBand[1]}`,
2929
+ sourceUrl: first.url,
2930
+ hardwareRequirements: hardware ? [hardware] : void 0,
2931
+ softwareRequirements: software ? [software] : void 0
2932
+ }
2933
+ ];
2934
+ factsheet.evidenceBacked = true;
2935
+ }
2926
2936
  }
2927
2937
  factsheet.markdownReport = this.renderMarkdownReport(factsheet);
2928
2938
  return factsheet;
@@ -2936,23 +2946,41 @@ Synthesize a strictly valid JSON object with:`,
2936
2946
  `- **Hardware:** ${fs.compatibilityMatrix.hardwarePlatform || "N/A"}`,
2937
2947
  `- **Software / SDK:** ${fs.compatibilityMatrix.softwareEnv || "N/A"}`,
2938
2948
  `- **Verdict:** ${fs.compatibilityMatrix.verifiedCompatible ? "\u2705 Verified Compatible" : "\u26A0\uFE0F Compatibility Warning"}`,
2939
- ...fs.compatibilityMatrix.notes.map((n) => ` - ${n}`),
2940
- `
2949
+ ...fs.compatibilityMatrix.notes.map((n) => ` - ${n}`)
2950
+ ];
2951
+ if (fs.ageFeasibility.potentialBarriers.length > 0) {
2952
+ lines.push(
2953
+ `
2941
2954
  ## 2. Age Feasibility & Learner Barriers (Ages ${fs.ageFeasibility.recommendedMinAge}\u2013${fs.ageFeasibility.recommendedMaxAge})`,
2942
- ...fs.ageFeasibility.potentialBarriers.map((b) => `- \u26A0\uFE0F ${b}`),
2943
- `
2955
+ ...fs.ageFeasibility.potentialBarriers.map((b) => `- \u26A0\uFE0F ${b}`)
2956
+ );
2957
+ }
2958
+ if (fs.exemplarProjects.length > 0) {
2959
+ lines.push(
2960
+ `
2944
2961
  ## 3. Real-World Exemplar Projects`,
2945
- ...fs.exemplarProjects.map((ex, idx) => `### Exemplar ${idx + 1}: ${ex.title}
2962
+ ...fs.exemplarProjects.map(
2963
+ (ex, idx) => `### Exemplar ${idx + 1}: ${ex.title}
2946
2964
  - **Summary:** ${ex.description}
2947
2965
  - **Audience:** ${ex.targetAudience}${ex.sourceUrl ? `
2948
- - **Reference:** [Link](${ex.sourceUrl})` : ""}`),
2949
- `
2966
+ - **Reference:** [Link](${ex.sourceUrl})` : ""}`
2967
+ )
2968
+ );
2969
+ }
2970
+ if (fs.technicalBottlenecks.length > 0) {
2971
+ lines.push(
2972
+ `
2950
2973
  ## 4. Technical Bottlenecks & Pitfalls to Avoid`,
2951
- ...fs.technicalBottlenecks.map((bn) => `- \u{1F6D1} ${bn}`),
2952
- `
2974
+ ...fs.technicalBottlenecks.map((bn) => `- \u{1F6D1} ${bn}`)
2975
+ );
2976
+ }
2977
+ if (fs.groundingSources.length > 0) {
2978
+ lines.push(
2979
+ `
2953
2980
  ## 5. Grounding Citations`,
2954
- ...fs.groundingSources.map((s, idx) => `${idx + 1}. [${s.title}](${s.url})`)
2955
- ];
2981
+ ...fs.groundingSources.map((s, idx) => `${idx + 1}. [${s.title}](${s.url})`)
2982
+ );
2983
+ }
2956
2984
  if (fs.codeSnippets && fs.codeSnippets.length > 0) {
2957
2985
  lines.push(
2958
2986
  `
@@ -2963,11 +2991,8 @@ ${c.code}
2963
2991
  );
2964
2992
  }
2965
2993
  if (fs.pinoutTables && fs.pinoutTables.length > 0) {
2966
- lines.push(
2967
- `
2968
- ## 7. Pinout & Specification Tables`,
2969
- ...fs.pinoutTables
2970
- );
2994
+ lines.push(`
2995
+ ## 7. Pinout & Specification Tables`, ...fs.pinoutTables);
2971
2996
  }
2972
2997
  return lines.join("\n");
2973
2998
  }