@thanh01.pmt/research-kit 1.0.0 → 1.1.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 (78) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +213 -0
  3. package/dist/academic/index.cjs +332 -127
  4. package/dist/academic/index.cjs.map +1 -1
  5. package/dist/academic/index.d.cts +3 -3
  6. package/dist/academic/index.d.ts +3 -3
  7. package/dist/academic/index.js +2 -2
  8. package/dist/{catalogBuilder-8A-Dg_A-.d.ts → catalogBuilder-CmmQzUnf.d.ts} +11 -3
  9. package/dist/{catalogBuilder-feU79wQQ.d.cts → catalogBuilder-DgXYxL2F.d.cts} +11 -3
  10. package/dist/chunk-2JEVBCIF.js +3 -0
  11. package/dist/{chunk-KGCDYFFD.js.map → chunk-2JEVBCIF.js.map} +1 -1
  12. package/dist/chunk-2XIEWCUE.js +244 -0
  13. package/dist/chunk-2XIEWCUE.js.map +1 -0
  14. package/dist/chunk-AUGVVZTL.js +514 -0
  15. package/dist/chunk-AUGVVZTL.js.map +1 -0
  16. package/dist/chunk-DOXSPRSP.js +559 -0
  17. package/dist/chunk-DOXSPRSP.js.map +1 -0
  18. package/dist/chunk-GKF3NDEX.js +162 -0
  19. package/dist/chunk-GKF3NDEX.js.map +1 -0
  20. package/dist/chunk-J3VCGH7Z.js +3 -0
  21. package/dist/chunk-J3VCGH7Z.js.map +1 -0
  22. package/dist/{chunk-67V2GJGK.js → chunk-J7XKDMGL.js} +7 -5
  23. package/dist/chunk-J7XKDMGL.js.map +1 -0
  24. package/dist/chunk-KAFQVI2R.js +333 -0
  25. package/dist/chunk-KAFQVI2R.js.map +1 -0
  26. package/dist/chunk-XIF5YNI7.js +799 -0
  27. package/dist/chunk-XIF5YNI7.js.map +1 -0
  28. package/dist/config/index.cjs +5 -3
  29. package/dist/config/index.cjs.map +1 -1
  30. package/dist/config/index.d.cts +1 -1
  31. package/dist/config/index.d.ts +1 -1
  32. package/dist/config/index.js +1 -1
  33. package/dist/evidence/index.cjs +337 -21
  34. package/dist/evidence/index.cjs.map +1 -1
  35. package/dist/evidence/index.d.cts +44 -7
  36. package/dist/evidence/index.d.ts +44 -7
  37. package/dist/evidence/index.js +3 -2
  38. package/dist/harvester/index.cjs +805 -64
  39. package/dist/harvester/index.cjs.map +1 -1
  40. package/dist/harvester/index.d.cts +79 -8
  41. package/dist/harvester/index.d.ts +79 -8
  42. package/dist/harvester/index.js +3 -2
  43. package/dist/{index-BU5n1ip_.d.ts → index-t8pahlJ4.d.cts} +104 -15
  44. package/dist/{index-BU5n1ip_.d.cts → index-t8pahlJ4.d.ts} +104 -15
  45. package/dist/index.cjs +2001 -252
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.cts +156 -8
  48. package/dist/index.d.ts +156 -8
  49. package/dist/index.js +237 -8
  50. package/dist/index.js.map +1 -1
  51. package/dist/literatureReview-BTPFe7eb.d.cts +64 -0
  52. package/dist/literatureReview-hGbfrBmw.d.ts +64 -0
  53. package/dist/pipeline/index.cjs +1570 -241
  54. package/dist/pipeline/index.cjs.map +1 -1
  55. package/dist/pipeline/index.d.cts +49 -9
  56. package/dist/pipeline/index.d.ts +49 -9
  57. package/dist/pipeline/index.js +5 -4
  58. package/dist/webScraper-BhiQ8s9x.d.ts +68 -0
  59. package/dist/webScraper-D9Ldus9p.d.cts +68 -0
  60. package/package.json +8 -9
  61. package/dist/chunk-47L7ZHMY.js +0 -316
  62. package/dist/chunk-47L7ZHMY.js.map +0 -1
  63. package/dist/chunk-63X2HPCI.js +0 -47
  64. package/dist/chunk-63X2HPCI.js.map +0 -1
  65. package/dist/chunk-67V2GJGK.js.map +0 -1
  66. package/dist/chunk-6Q2XCUG7.js +0 -40
  67. package/dist/chunk-6Q2XCUG7.js.map +0 -1
  68. package/dist/chunk-KGCDYFFD.js +0 -3
  69. package/dist/chunk-MHAYD555.js +0 -239
  70. package/dist/chunk-MHAYD555.js.map +0 -1
  71. package/dist/chunk-MPLDSHFM.js +0 -396
  72. package/dist/chunk-MPLDSHFM.js.map +0 -1
  73. package/dist/chunk-QZNLB5X4.js +0 -65
  74. package/dist/chunk-QZNLB5X4.js.map +0 -1
  75. package/dist/literatureReview-C4AgVljZ.d.ts +0 -43
  76. package/dist/literatureReview-Dlods4Aw.d.cts +0 -43
  77. package/dist/webScraper-pKzdXhfI.d.ts +0 -46
  78. package/dist/webScraper-yBcYOHoL.d.cts +0 -46
@@ -2,6 +2,52 @@
2
2
 
3
3
  var zod = require('zod');
4
4
 
5
+ // src/academic/semanticScholar.ts
6
+
7
+ // src/academic/arxivClient.ts
8
+ var ArXivSearchEngine = class {
9
+ /**
10
+ * Search ArXiv repository using the public atom XML API
11
+ */
12
+ async search(query, maxResults = 5) {
13
+ const papers = [];
14
+ try {
15
+ const url = `https://export.arxiv.org/api/query?search_query=all:${encodeURIComponent(query)}&start=0&max_results=${maxResults}&sortBy=relevance&sortOrder=descending`;
16
+ const res = await fetch(url, { signal: AbortSignal.timeout(1e4) });
17
+ if (res.ok) {
18
+ const xmlText = await res.text();
19
+ const entryMatches = xmlText.match(/<entry>[\s\S]*?<\/entry>/g) || [];
20
+ for (const entry of entryMatches) {
21
+ const idMatch = entry.match(/<id>([\s\S]*?)<\/id>/);
22
+ const titleMatch = entry.match(/<title>([\s\S]*?)<\/title>/);
23
+ const summaryMatch = entry.match(/<summary>([\s\S]*?)<\/summary>/);
24
+ const publishedMatch = entry.match(/<published>(\d{4})/);
25
+ const authorMatches = [...entry.matchAll(/<author>\s*<name>([\s\S]*?)<\/name>/g)].map((m) => m[1]?.trim()).filter(Boolean);
26
+ const arxivUrl = idMatch ? idMatch[1]?.trim() : "";
27
+ const pdfUrl = arxivUrl ? arxivUrl.replace("/abs/", "/pdf/") + ".pdf" : void 0;
28
+ if (titleMatch) {
29
+ papers.push({
30
+ id: arxivUrl || `arxiv-${Math.random().toString(36).substring(7)}`,
31
+ title: titleMatch[1]?.trim().replace(/\s+/g, " ") || "Untitled ArXiv Paper",
32
+ abstract: summaryMatch ? summaryMatch[1]?.trim().replace(/\s+/g, " ") : "",
33
+ authors: authorMatches,
34
+ year: publishedMatch ? parseInt(publishedMatch[1], 10) : (/* @__PURE__ */ new Date()).getFullYear(),
35
+ citationCount: 0,
36
+ venue: "arXiv preprint",
37
+ url: arxivUrl,
38
+ pdfUrl,
39
+ fieldsOfStudy: ["Computer Science", "AI & Machine Learning"]
40
+ });
41
+ }
42
+ }
43
+ }
44
+ } catch (e) {
45
+ console.warn("[ArXivSearchEngine] ArXiv search failed:", e?.message || e);
46
+ }
47
+ return papers;
48
+ }
49
+ };
50
+
5
51
  // src/academic/semanticScholar.ts
6
52
  var AcademicPaperSchema = zod.z.object({
7
53
  id: zod.z.string(),
@@ -17,22 +63,56 @@ var AcademicPaperSchema = zod.z.object({
17
63
  tldr: zod.z.string().optional(),
18
64
  fieldsOfStudy: zod.z.array(zod.z.string()).default([])
19
65
  });
66
+ function reconstructOpenAlexAbstract(invertedIndex) {
67
+ if (!invertedIndex || typeof invertedIndex !== "object") return void 0;
68
+ const entries = Object.entries(invertedIndex);
69
+ if (entries.length === 0) return void 0;
70
+ let maxIndex = 0;
71
+ for (const [, positions] of entries) {
72
+ if (Array.isArray(positions)) {
73
+ for (const p of positions) {
74
+ if (typeof p === "number" && p > maxIndex) maxIndex = p;
75
+ }
76
+ }
77
+ }
78
+ if (maxIndex > 5e3) maxIndex = 5e3;
79
+ const words = new Array(maxIndex + 1);
80
+ for (const [word, positions] of entries) {
81
+ if (Array.isArray(positions)) {
82
+ for (const p of positions) {
83
+ if (typeof p === "number" && p >= 0 && p <= maxIndex) {
84
+ words[p] = word;
85
+ }
86
+ }
87
+ }
88
+ }
89
+ const reconstructed = words.filter(Boolean).join(" ").trim();
90
+ return reconstructed.length > 0 ? reconstructed : void 0;
91
+ }
20
92
  var AcademicSearchEngine = class {
21
93
  apiKey;
94
+ allowEnvFallback;
22
95
  customAdapter;
96
+ arxivEngine;
23
97
  constructor(options = {}) {
98
+ this.arxivEngine = new ArXivSearchEngine();
24
99
  if (typeof options === "string") {
25
100
  this.apiKey = options;
101
+ this.allowEnvFallback = true;
26
102
  } else {
27
- this.apiKey = options.apiKey || process.env.SEMANTIC_SCHOLAR_API_KEY;
103
+ this.allowEnvFallback = options.allowEnvFallback ?? true;
104
+ this.apiKey = options.apiKey || (this.allowEnvFallback ? process.env.SEMANTIC_SCHOLAR_API_KEY : void 0);
28
105
  this.customAdapter = options.customAdapter;
29
106
  }
30
107
  }
31
108
  setCustomAdapter(adapter) {
32
109
  this.customAdapter = adapter;
33
110
  }
111
+ setApiKey(apiKey) {
112
+ this.apiKey = apiKey;
113
+ }
34
114
  /**
35
- * Search academic papers across Semantic Scholar with OpenAlex fallback or Custom Adapter
115
+ * Search academic papers across Semantic Scholar with OpenAlex and ArXiv fallback or Custom Adapter
36
116
  */
37
117
  async searchPapers(query, options = {}) {
38
118
  const adapter = options.customAdapter || this.customAdapter;
@@ -48,6 +128,13 @@ var AcademicSearchEngine = class {
48
128
  }
49
129
  const limit = options.limit ?? 5;
50
130
  const papers = [];
131
+ const seenTitles = /* @__PURE__ */ new Set();
132
+ const pushUnique = (p) => {
133
+ const normTitle = p.title.toLowerCase().replace(/[^a-z0-9\u00C0-\u1EF9]+/g, "");
134
+ if (!normTitle || seenTitles.has(normTitle)) return;
135
+ seenTitles.add(normTitle);
136
+ papers.push(p);
137
+ };
51
138
  try {
52
139
  const apiKey = options.apiKey || this.apiKey;
53
140
  const headers = { "Content-Type": "application/json" };
@@ -70,104 +157,111 @@ var AcademicSearchEngine = class {
70
157
  const data = await res.json();
71
158
  if (Array.isArray(data?.data)) {
72
159
  for (const item of data.data) {
73
- papers.push({
160
+ pushUnique({
74
161
  id: item.paperId || `s2-${Math.random().toString(36).slice(2, 8)}`,
75
162
  title: item.title || "Untitled",
76
- abstract: item.abstract,
77
- authors: Array.isArray(item.authors) ? item.authors.map((a) => a.name) : [],
163
+ abstract: item.abstract || void 0,
164
+ authors: Array.isArray(item.authors) ? item.authors.map((a) => a.name).filter(Boolean) : [],
78
165
  year: item.year,
79
166
  citationCount: item.citationCount || 0,
80
- venue: item.venue,
167
+ venue: item.venue || void 0,
81
168
  doi: item.externalIds?.DOI,
82
- url: item.url,
169
+ url: item.url || (item.externalIds?.DOI ? `https://doi.org/${item.externalIds.DOI}` : void 0),
83
170
  pdfUrl: item.openAccessPdf?.url,
84
171
  tldr: item.tldr?.text,
85
- fieldsOfStudy: item.fieldsOfStudy || ["Computer Science"]
172
+ fieldsOfStudy: Array.isArray(item.fieldsOfStudy) && item.fieldsOfStudy.length > 0 ? item.fieldsOfStudy : ["Computer Science"]
86
173
  });
87
174
  }
88
- if (papers.length > 0) return papers;
175
+ if (papers.length >= limit) return papers.slice(0, limit);
89
176
  }
90
177
  }
91
178
  } catch (e) {
92
179
  console.warn("[AcademicSearchEngine] Semantic Scholar failed:", e?.message || e);
93
180
  }
94
- try {
95
- const res = await fetch(`https://api.openalex.org/works?search=${encodeURIComponent(query)}&per-page=${limit}`, {
96
- headers: { "User-Agent": "OrchableComposer/1.0 (mailto:team@orchable.app)" },
97
- signal: AbortSignal.timeout(6e3)
98
- });
99
- if (res.ok) {
100
- const data = await res.json();
101
- if (Array.isArray(data?.results)) {
102
- for (const item of data.results) {
103
- papers.push({
104
- id: item.id || `oa-${Math.random().toString(36).slice(2, 8)}`,
105
- title: item.title || "Untitled",
106
- abstract: item.abstract_inverted_index ? "Abstract indexed" : void 0,
107
- authors: Array.isArray(item.authorships) ? item.authorships.map((a) => a.author?.display_name).filter(Boolean) : [],
108
- year: item.publication_year,
109
- citationCount: item.cited_by_count || 0,
110
- venue: item.primary_location?.source?.display_name,
111
- doi: item.doi,
112
- url: item.doi || item.id,
113
- pdfUrl: item.open_access?.oa_url,
114
- fieldsOfStudy: ["Computer Science"]
115
- });
181
+ if (papers.length < limit) {
182
+ try {
183
+ const res = await fetch(`https://api.openalex.org/works?search=${encodeURIComponent(query)}&per-page=${limit}`, {
184
+ headers: { "User-Agent": "OrchableComposer/1.0 (mailto:team@orchable.app)" },
185
+ signal: AbortSignal.timeout(6e3)
186
+ });
187
+ if (res.ok) {
188
+ const data = await res.json();
189
+ if (Array.isArray(data?.results)) {
190
+ for (const item of data.results) {
191
+ const abstractText = reconstructOpenAlexAbstract(item.abstract_inverted_index);
192
+ const concepts = Array.isArray(item.concepts) ? item.concepts.slice(0, 3).map((c) => c.display_name).filter(Boolean) : ["Computer Science"];
193
+ pushUnique({
194
+ id: item.id || `oa-${Math.random().toString(36).slice(2, 8)}`,
195
+ title: item.title || "Untitled",
196
+ abstract: abstractText,
197
+ authors: Array.isArray(item.authorships) ? item.authorships.map((a) => a.author?.display_name).filter(Boolean) : [],
198
+ year: item.publication_year,
199
+ citationCount: item.cited_by_count || 0,
200
+ venue: item.primary_location?.source?.display_name,
201
+ doi: item.doi ? String(item.doi).replace(/^https?:\/\/doi\.org\//i, "") : void 0,
202
+ url: item.doi || item.id,
203
+ pdfUrl: item.open_access?.oa_url,
204
+ fieldsOfStudy: concepts.length > 0 ? concepts : ["Computer Science"]
205
+ });
206
+ }
116
207
  }
117
208
  }
209
+ } catch (e) {
210
+ console.warn("[AcademicSearchEngine] OpenAlex failed:", e?.message || e);
118
211
  }
119
- } catch (e) {
120
- console.warn("[AcademicSearchEngine] OpenAlex failed:", e?.message || e);
121
212
  }
122
- return papers;
123
- }
124
- };
125
-
126
- // src/academic/arxivClient.ts
127
- var ArXivSearchEngine = class {
128
- /**
129
- * Search ArXiv repository using the public atom XML API
130
- */
131
- async search(query, maxResults = 5) {
132
- const papers = [];
133
- try {
134
- const url = `http://export.arxiv.org/api/query?search_query=all:${encodeURIComponent(query)}&start=0&max_results=${maxResults}&sortBy=relevance&sortOrder=descending`;
135
- const res = await fetch(url, { signal: AbortSignal.timeout(1e4) });
136
- if (res.ok) {
137
- const xmlText = await res.text();
138
- const entryMatches = xmlText.match(/<entry>[\s\S]*?<\/entry>/g) || [];
139
- for (const entry of entryMatches) {
140
- const idMatch = entry.match(/<id>([\s\S]*?)<\/id>/);
141
- const titleMatch = entry.match(/<title>([\s\S]*?)<\/title>/);
142
- const summaryMatch = entry.match(/<summary>([\s\S]*?)<\/summary>/);
143
- const publishedMatch = entry.match(/<published>(\d{4})/);
144
- const authorMatches = [...entry.matchAll(/<author>\s*<name>([\s\S]*?)<\/name>/g)].map((m) => m[1]?.trim()).filter(Boolean);
145
- const arxivUrl = idMatch ? idMatch[1]?.trim() : "";
146
- const pdfUrl = arxivUrl ? arxivUrl.replace("/abs/", "/pdf/") + ".pdf" : void 0;
147
- if (titleMatch) {
148
- papers.push({
149
- id: arxivUrl || `arxiv-${Math.random().toString(36).substring(7)}`,
150
- title: titleMatch[1]?.trim().replace(/\s+/g, " ") || "Untitled ArXiv Paper",
151
- abstract: summaryMatch ? summaryMatch[1]?.trim().replace(/\s+/g, " ") : "",
152
- authors: authorMatches,
153
- year: publishedMatch ? parseInt(publishedMatch[1], 10) : (/* @__PURE__ */ new Date()).getFullYear(),
154
- citationCount: 0,
155
- venue: "arXiv preprint",
156
- url: arxivUrl,
157
- pdfUrl,
158
- fieldsOfStudy: ["Computer Science", "AI & Machine Learning"]
159
- });
160
- }
213
+ if (papers.length < limit && options.includeArxivFallback !== false) {
214
+ try {
215
+ const arxivPapers = await this.arxivEngine.search(query, limit - papers.length);
216
+ for (const p of arxivPapers) {
217
+ pushUnique(p);
161
218
  }
219
+ } catch (e) {
220
+ console.warn("[AcademicSearchEngine] ArXiv fallback failed:", e?.message || e);
162
221
  }
163
- } catch (e) {
164
- console.warn("[ArXivSearchEngine] ArXiv search failed:", e?.message || e);
165
222
  }
166
- return papers;
223
+ return papers.slice(0, limit);
167
224
  }
168
225
  };
169
226
 
170
227
  // src/academic/cs2023Taxonomy.ts
228
+ var CSTA_K12_STRANDS = {
229
+ CS: {
230
+ code: "CS",
231
+ name: "Computing Systems",
232
+ nameVi: "H\u1EC7 th\u1ED1ng M\xE1y t\xEDnh & Ph\u1EA7n c\u1EE9ng",
233
+ description: "Devices, hardware and software integration, sensors, actuators, and troubleshooting.",
234
+ subconcepts: ["Devices", "Hardware & Software", "Troubleshooting"]
235
+ },
236
+ NI: {
237
+ code: "NI",
238
+ name: "Networks and the Internet",
239
+ nameVi: "M\u1EA1ng m\xE1y t\xEDnh & An to\xE0n th\xF4ng tin",
240
+ description: "Network communication, protocols, IoT connectivity, and cybersecurity.",
241
+ subconcepts: ["Network Communication & Organization", "Cybersecurity"]
242
+ },
243
+ DA: {
244
+ code: "DA",
245
+ name: "Data and Analysis",
246
+ nameVi: "D\u1EEF li\u1EC7u & Ph\xE2n t\xEDch",
247
+ description: "Storage, collection, visualization, and transformation of sensor or application data.",
248
+ subconcepts: ["Storage", "Collection, Visualization & Transformation", "Inference & Models"]
249
+ },
250
+ AP: {
251
+ code: "AP",
252
+ name: "Algorithms and Programming",
253
+ nameVi: "Thu\u1EADt to\xE1n & L\u1EADp tr\xECnh",
254
+ description: "Algorithms, variables, control structures, modularity, and iterative program development.",
255
+ subconcepts: ["Algorithms", "Variables", "Control", "Modularity", "Program Development"]
256
+ },
257
+ IC: {
258
+ code: "IC",
259
+ name: "Impacts of Computing",
260
+ nameVi: "T\xE1c \u0111\u1ED9ng c\u1EE7a Tin h\u1ECDc & AI",
261
+ description: "Culture, social interactions, safety, law, and ethics of computing and AI systems.",
262
+ subconcepts: ["Culture", "Social Interactions", "Safety, Law, & Ethics"]
263
+ }
264
+ };
171
265
  var CS2023_KNOWLEDGE_AREAS = {
172
266
  AL: {
173
267
  code: "AL",
@@ -178,8 +272,8 @@ var CS2023_KNOWLEDGE_AREAS = {
178
272
  AR: {
179
273
  code: "AR",
180
274
  name: "Architecture and Organization",
181
- description: "Hardware architecture, assembly, memory hierarchy, pipelining, and system bus.",
182
- coreTopics: ["Digital Logic", "Memory Hierarchy & Cache", "Instruction Set Architecture (ISA)", "Interfacing & I/O"]
275
+ description: "Hardware architecture, microcontrollers, sensors, memory hierarchy, and interfacing.",
276
+ coreTopics: ["Digital Logic", "Memory Hierarchy & Cache", "Microcontrollers & Embedded I/O", "Sensor & Actuator Interfacing"]
183
277
  },
184
278
  AI: {
185
279
  code: "AI",
@@ -187,6 +281,30 @@ var CS2023_KNOWLEDGE_AREAS = {
187
281
  description: "Neural networks, search algorithms, knowledge representation, reinforcement learning, and LLMs.",
188
282
  coreTopics: ["Supervised Learning", "Deep Learning & Transformers", "Search & Optimization", "AI Ethics & Alignment"]
189
283
  },
284
+ DM: {
285
+ code: "DM",
286
+ name: "Data Management",
287
+ description: "Relational databases, NoSQL, query optimization, data modeling, and transactions.",
288
+ coreTopics: ["Relational & SQL Modeling", "Indexing & Query Optimization", "Transactions & ACID", "Distributed Data Stores"]
289
+ },
290
+ FPL: {
291
+ code: "FPL",
292
+ name: "Foundations of Programming Languages",
293
+ description: "Language paradigms, type systems, event-driven programming, memory safety, and compilers.",
294
+ coreTopics: ["Event-Driven & Reactive Programming", "Functional & OOP Paradigms", "Static & Dynamic Typing", "Memory Safety & Ownership"]
295
+ },
296
+ GIT: {
297
+ code: "GIT",
298
+ name: "Graphics and Interactive Techniques",
299
+ description: "Game engines, 2D/3D rendering, physics simulation, collision detection, and interactive media.",
300
+ coreTopics: ["Game Loop & Frame Timing", "2D/3D Coordinate Systems & Physics", "Collision Detection & State Machines", "Shader & Rendering Pipelines"]
301
+ },
302
+ HCI: {
303
+ code: "HCI",
304
+ name: "Human-Computer Interaction",
305
+ description: "User interface design, usability, accessibility, state-driven UI frameworks, and interaction loops.",
306
+ coreTopics: ["Declarative & State-Driven UI", "Usability & Cognitive Ergonomics", "Accessibility Standards", "Interactive Prototyping"]
307
+ },
190
308
  OS: {
191
309
  code: "OS",
192
310
  name: "Operating Systems",
@@ -205,6 +323,12 @@ var CS2023_KNOWLEDGE_AREAS = {
205
323
  description: "Language paradigms, type systems, memory safety, compilers, and runtime environments.",
206
324
  coreTopics: ["Functional & OOP Paradigms", "Static & Dynamic Typing", "Memory Safety & Ownership", "Language Runtimes"]
207
325
  },
326
+ SDF: {
327
+ code: "SDF",
328
+ name: "Software Development Fundamentals",
329
+ description: "Core programming constructs, variables, control flow, data structures, debugging, and modularization.",
330
+ coreTopics: ["Variables, Loops & Control Flow", "Data Structures (Arrays, Lists, Maps)", "Systematic Debugging & Testing", "Modular & Procedural Design"]
331
+ },
208
332
  SE: {
209
333
  code: "SE",
210
334
  name: "Software Engineering",
@@ -217,37 +341,53 @@ var CS2023_KNOWLEDGE_AREAS = {
217
341
  description: "Authentication, cryptography, secure coding, threat modeling, and network defense.",
218
342
  coreTopics: ["Symmetric & Asymmetric Encryption", "OAuth & JWT Auth", "Secure Coding & Vulnerabilities", "Identity & Access Management"]
219
343
  },
220
- SDF: {
221
- code: "SDF",
222
- name: "Software Development Fundamentals",
223
- description: "Core programming constructs, data structures, debugging, and modularization.",
224
- coreTopics: ["Variables, Loops & Control Flow", "Data Structures (Arrays, Lists, Trees)", "Debugging & Version Control", "OOP & Modular Design"]
344
+ SPD: {
345
+ code: "SPD",
346
+ name: "Specialized Platform Development",
347
+ description: "Web, mobile, cloud, IoT, and robotics platform engineering.",
348
+ coreTopics: ["Mobile & Desktop App Lifecycle", "Web Full-Stack Architecture", "IoT & Edge Device Connectivity", "Platform SDK Integration"]
225
349
  }
226
350
  };
227
- function mapTopicToCS2023(topic) {
228
- const t = topic.toLowerCase();
229
- if (t.includes("concurren") || t.includes("async") || t.includes("actor") || t.includes("thread") || t.includes("distributed")) {
230
- return { area: CS2023_KNOWLEDGE_AREAS.PDC, matchConfidence: 0.95 };
351
+ function mapTopicToCS2023(topic, context) {
352
+ const combined = [
353
+ topic,
354
+ context?.courseTitle,
355
+ context?.positioning,
356
+ context?.hardwarePlatform,
357
+ context?.softwareEnv,
358
+ ...context?.inScopeTopics || []
359
+ ].filter(Boolean).join(" ").toLowerCase();
360
+ if (/\b(concurren|async|actor|thread|distributed|parallel|đồng thời|bất đồng bộ|đa luồng)\b/.test(combined)) {
361
+ return { area: CS2023_KNOWLEDGE_AREAS.PDC, k12Strand: CSTA_K12_STRANDS.AP, matchConfidence: 0.95 };
362
+ }
363
+ if (/\b(ai|machine learning|deep learning|neural|llm|computer vision|trí tuệ nhân tạo|học máy|mạng nơ-ron)\b/.test(combined)) {
364
+ return { area: CS2023_KNOWLEDGE_AREAS.AI, k12Strand: CSTA_K12_STRANDS.DA, matchConfidence: 0.95 };
231
365
  }
232
- if (t.includes("ai") || t.includes("machine learning") || t.includes("deep learning") || t.includes("robot") || t.includes("neural")) {
233
- return { area: CS2023_KNOWLEDGE_AREAS.AI, matchConfidence: 0.95 };
366
+ if (/\b(arduino|esp32|raspberry|micro:?bit|mblock|makecode|lego|sensor|circuit|gpio|iot|hardware|robotics|cảm biến|vi điều khiển|mạch điện|điện tử)\b/.test(combined)) {
367
+ return { area: CS2023_KNOWLEDGE_AREAS.AR, k12Strand: CSTA_K12_STRANDS.CS, matchConfidence: 0.92 };
234
368
  }
235
- if (t.includes("os") || t.includes("operating system") || t.includes("kernel") || t.includes("memory") || t.includes("linux")) {
236
- return { area: CS2023_KNOWLEDGE_AREAS.OS, matchConfidence: 0.9 };
369
+ if (/\b(roblox|unity|godot|pygame|game|2d|3d|sprite|collision|physics|shader|trò chơi|làm game)\b/.test(combined)) {
370
+ return { area: CS2023_KNOWLEDGE_AREAS.GIT, k12Strand: CSTA_K12_STRANDS.AP, matchConfidence: 0.92 };
237
371
  }
238
- if (t.includes("security") || t.includes("auth") || t.includes("crypto") || t.includes("cyber")) {
239
- return { area: CS2023_KNOWLEDGE_AREAS.SEC, matchConfidence: 0.9 };
372
+ if (/\b(swiftui|ui|ux|interface|frontend|accessibility|figma|giao diện|tương tác người-máy)\b/.test(combined)) {
373
+ return { area: CS2023_KNOWLEDGE_AREAS.HCI, k12Strand: CSTA_K12_STRANDS.AP, matchConfidence: 0.9 };
240
374
  }
241
- if (t.includes("architecture") || t.includes("pattern") || t.includes("software engineer") || t.includes("clean code")) {
242
- return { area: CS2023_KNOWLEDGE_AREAS.SE, matchConfidence: 0.85 };
375
+ if (/\b(os|operating system|kernel|virtual memory|linux|hệ điều hành)\b/.test(combined)) {
376
+ return { area: CS2023_KNOWLEDGE_AREAS.OS, k12Strand: CSTA_K12_STRANDS.CS, matchConfidence: 0.9 };
243
377
  }
244
- if (t.includes("algorithm") || t.includes("data structure") || t.includes("tree") || t.includes("graph")) {
245
- return { area: CS2023_KNOWLEDGE_AREAS.AL, matchConfidence: 0.9 };
378
+ if (/\b(security|auth|crypto|cyber|jwt|oauth|bảo mật|an toàn thông tin|mã hóa)\b/.test(combined)) {
379
+ return { area: CS2023_KNOWLEDGE_AREAS.SEC, k12Strand: CSTA_K12_STRANDS.NI, matchConfidence: 0.9 };
246
380
  }
247
- if (t.includes("arduino") || t.includes("esp32") || t.includes("raspberry") || t.includes("hardware") || t.includes("circuit")) {
248
- return { area: CS2023_KNOWLEDGE_AREAS.AR, matchConfidence: 0.9 };
381
+ if (/\b(sql|database|postgres|supabase|mongodb|data model|cơ sở dữ liệu|truy vấn)\b/.test(combined)) {
382
+ return { area: CS2023_KNOWLEDGE_AREAS.DM, k12Strand: CSTA_K12_STRANDS.DA, matchConfidence: 0.9 };
249
383
  }
250
- return { area: CS2023_KNOWLEDGE_AREAS.SDF, matchConfidence: 0.7 };
384
+ if (/\b(architecture|design pattern|software engineer|clean code|testing|tdd|ci\/cd|kiến trúc phần mềm|kiểm thử)\b/.test(combined)) {
385
+ return { area: CS2023_KNOWLEDGE_AREAS.SE, k12Strand: CSTA_K12_STRANDS.AP, matchConfidence: 0.88 };
386
+ }
387
+ if (/\b(algorithm|data structure|tree|graph|dynamic programming|sorting|thuật toán|cấu trúc dữ liệu|đồ thị|quy hoạch động)\b/.test(combined)) {
388
+ return { area: CS2023_KNOWLEDGE_AREAS.AL, k12Strand: CSTA_K12_STRANDS.AP, matchConfidence: 0.9 };
389
+ }
390
+ return { area: CS2023_KNOWLEDGE_AREAS.SDF, k12Strand: CSTA_K12_STRANDS.AP, matchConfidence: 0.8 };
251
391
  }
252
392
 
253
393
  // src/academic/citationManager.ts
@@ -299,70 +439,135 @@ var CitationManager = class {
299
439
 
300
440
  // src/academic/literatureReview.ts
301
441
  var LiteratureReviewSynthesizer = class {
302
- synthesize(topic, papers, cs2023Area) {
442
+ synthesize(topic, papers, cs2023Area, k12Strand) {
303
443
  const citationManager = new CitationManager();
304
444
  const sotaMatrix = [];
445
+ const foundations = [];
305
446
  for (const paper of papers) {
306
447
  citationManager.addPaper(paper);
448
+ const summaryText = paper.tldr?.trim() || (paper.abstract ? paper.abstract.trim().split(/(?<=[.!?])\s+/)[0] || paper.abstract.slice(0, 160) : "");
307
449
  sotaMatrix.push({
308
- approach: paper.title.split(":")[0] || paper.title.slice(0, 30),
309
- sourcePaper: `${paper.authors[0] || "Unknown"} (${paper.year || "n.d."})`,
310
- keyStrengths: paper.tldr || (paper.abstract ? paper.abstract.slice(0, 120) + "..." : "Foundational theoretical concept"),
311
- limitations: "Context-specific or hardware-constrained",
312
- relevanceToCourse: `Informs pedagogical sequencing and theoretical grounding for ${topic}.`
450
+ approach: paper.title.split(":")[0]?.trim() || paper.title.slice(0, 45),
451
+ sourcePaper: `${paper.authors[0] || "Unknown"} (${paper.year || "n.d."})${paper.venue ? ` \u2014 ${paper.venue}` : ""}`,
452
+ keyStrengths: summaryText ? summaryText.slice(0, 180) : `Peer-reviewed study (${paper.citationCount} citations)`,
453
+ limitations: paper.year && paper.year < 2020 ? `Published in ${paper.year}; verify against modern tooling` : "Requires pedagogical scaffolding for target learners",
454
+ relevanceToCourse: `Grounds "${topic}" in peer-reviewed evidence (${paper.fieldsOfStudy.slice(0, 2).join(", ") || "CS"}).`
313
455
  });
456
+ if (summaryText && foundations.length < 4) {
457
+ foundations.push(`[${paper.authors[0] || "Ref"} ${paper.year || ""}] ${summaryText}`);
458
+ }
459
+ }
460
+ if (cs2023Area) {
461
+ foundations.push(
462
+ `IEEE/ACM CS2023 (${cs2023Area.code} - ${cs2023Area.name}): ${cs2023Area.coreTopics.join(", ")}`
463
+ );
464
+ }
465
+ if (k12Strand) {
466
+ foundations.push(
467
+ `CSTA K-12 (${k12Strand.code} - ${k12Strand.name} / ${k12Strand.nameVi}): ${k12Strand.subconcepts.join(", ")}`
468
+ );
314
469
  }
470
+ const openQuestions = [
471
+ `How to scaffold core concepts of "${topic}" (${cs2023Area?.code || "CS"}) so learners master mental models before syntax memorization?`,
472
+ `What observable debugging and verification tasks best diagnose learner misconceptions in "${topic}"?`
473
+ ];
315
474
  const mdLines = [
316
475
  `# \u{1F393} Academic Literature Review & Theoretical Ground Truth`,
317
476
  `> **Topic:** ${topic}`,
318
- cs2023Area ? `> **IEEE/ACM CS2023 Standard Area:** \`${cs2023Area.code}\` \u2014 *${cs2023Area.name}*
477
+ cs2023Area ? `> **IEEE/ACM CS2023 Standard Area:** \`${cs2023Area.code}\` \u2014 *${cs2023Area.name}*` : "",
478
+ k12Strand ? `> **CSTA K-12 Strand:** \`${k12Strand.code}\` \u2014 *${k12Strand.name} (${k12Strand.nameVi})*
319
479
  ` : "",
320
480
  `## 1. Executive Summary`,
321
- `Synthesized from **${papers.length} peer-reviewed works** and international curricular standards directly relevant to \`${topic}\`.`,
481
+ papers.length > 0 ? `Synthesized from **${papers.length} peer-reviewed works** and curricular standards directly relevant to \`${topic}\`.` : `No peer-reviewed papers matched directly; aligned to curricular taxonomy standards for \`${topic}\`.`,
322
482
  `
323
483
  ## 2. State-of-the-Art (SOTA) Comparison Matrix`,
324
- `| Paradigm / Approach | Source Reference | Core Strengths | Constraints & Limitations | Pedagogical Application |`,
325
- `|---|---|---|---|---|`,
326
- ...sotaMatrix.map((r) => `| **${r.approach}** | ${r.sourcePaper} | ${r.keyStrengths} | ${r.limitations} | ${r.relevanceToCourse} |`),
484
+ ...sotaMatrix.length > 0 ? [
485
+ `| Paradigm / Approach | Source Reference | Core Findings / Abstract | Pedagogical Note | Course Application |`,
486
+ `|---|---|---|---|---|`,
487
+ ...sotaMatrix.map(
488
+ (r) => `| **${r.approach.replace(/\|/g, "/")}** | ${r.sourcePaper.replace(/\|/g, "/")} | ${r.keyStrengths.replace(/\|/g, "/")} | ${r.limitations.replace(/\|/g, "/")} | ${r.relevanceToCourse.replace(/\|/g, "/")} |`
489
+ )
490
+ ] : ["*No peer-reviewed papers returned from academic engines for this query.*"],
327
491
  `
328
- ## 3. Core Theoretical Foundations`,
329
- `- **Academic Rigor:** Curriculum models strictly adhere to peer-reviewed principles.`,
330
- `- **CS2023 Competency Alignment:** Maps directly to IEEE/ACM recommended graduate competencies.`,
331
- `- **Theory-to-Practice Bridge:** Direct translational pipeline from formal papers to executable lab operations.`,
492
+ ## 3. Core Theoretical & Curricular Foundations`,
493
+ ...foundations.map((f) => `- ${f}`),
332
494
  `
333
- ## 4. Open Pedagogical & Research Questions`,
334
- `- How to distill complex formal mechanisms for high-school / undergraduate learners without diluting accuracy?`,
335
- `- What automated verification setups validate theoretical guarantees in real-world student code?`,
495
+ ## 4. Open Pedagogical & Curriculum Design Questions`,
496
+ ...openQuestions.map((q) => `- ${q}`),
336
497
  `
337
498
  ${citationManager.getMarkdownFootnotes()}`
338
- ];
499
+ ].filter((line) => line !== "");
339
500
  return {
340
501
  topic,
341
502
  cs2023Area,
503
+ k12Strand,
342
504
  totalPapersFound: papers.length,
343
505
  papers,
344
506
  sotaMatrix,
345
- keyTheoreticalFoundations: [
346
- "Immutable state guarantees and memory safety semantics",
347
- "Dataflow and message-passing distributed concurrency models",
348
- "Empirical latency and throughput benchmark validation"
349
- ],
350
- openResearchQuestions: [
351
- "How to distill complex formal mechanisms for high-school / undergraduate learners without diluting accuracy?",
352
- "What automated verification setups validate theoretical guarantees in real-world student code?"
353
- ],
507
+ keyTheoreticalFoundations: foundations,
508
+ openResearchQuestions: openQuestions,
354
509
  markdownReport: mdLines.join("\n"),
355
510
  bibtex: citationManager.getBibTeX()
356
511
  };
357
512
  }
513
+ /**
514
+ * Optional LLM semantic synthesis of dynamic open research questions and pedagogical takeaways
515
+ * based on the retrieved academic literature.
516
+ */
517
+ async synthesizeWithLlm(topic, papers, cs2023Area, k12Strand, options = {}) {
518
+ const base = this.synthesize(topic, papers, cs2023Area, k12Strand);
519
+ if (!options.llm || papers.length === 0) {
520
+ return base;
521
+ }
522
+ try {
523
+ const abstractsSummary = papers.map((p, i) => `[Paper ${i + 1}] ${p.title} (${p.authors[0]} ${p.year}): ${p.tldr || p.abstract?.slice(0, 300) || "No abstract"}`).join("\n\n");
524
+ const prompt = [
525
+ `You are a Professor of Computing Education. Review these academic research papers retrieved for the course topic "${topic}".`,
526
+ cs2023Area ? `IEEE/ACM CS2023 Area: ${cs2023Area.code} - ${cs2023Area.name}` : "",
527
+ k12Strand ? `CSTA K-12 Strand: ${k12Strand.code} - ${k12Strand.name}` : "",
528
+ options.context?.ageBand ? `Target Age: ${options.context.ageBand[0]}-${options.context.ageBand[1]}` : "",
529
+ `
530
+ Retrieved Academic Papers:
531
+ ${abstractsSummary}`,
532
+ `
533
+ Generate 2-3 deep, actionable pedagogical research & curriculum design questions directly inspired by these papers.`,
534
+ `Return ONLY a JSON array of strings: ["Question 1", "Question 2"]`
535
+ ].filter(Boolean).join("\n");
536
+ const raw = await options.llm(prompt, {
537
+ system: "You are an educational research synthesis specialist. Output strictly a JSON array of strings.",
538
+ temperature: 0.2,
539
+ jsonMode: true
540
+ });
541
+ const match = raw.match(/\[[\s\S]*\]/);
542
+ if (match) {
543
+ const parsed = JSON.parse(match[0]);
544
+ if (Array.isArray(parsed) && parsed.length > 0) {
545
+ const dynamicQuestions = parsed.map(String).filter((q) => q.length > 10);
546
+ if (dynamicQuestions.length > 0) {
547
+ base.openResearchQuestions = dynamicQuestions;
548
+ base.markdownReport = base.markdownReport.replace(
549
+ /## 4\. Open Pedagogical & Curriculum Design Questions[\s\S]*?(?=\n\n\[\^|\n\n$|$)/,
550
+ `## 4. Open Pedagogical & Curriculum Design Questions
551
+ ${dynamicQuestions.map((q) => `- ${q}`).join("\n")}`
552
+ );
553
+ }
554
+ }
555
+ }
556
+ } catch (e) {
557
+ console.warn("[LiteratureReviewSynthesizer] LLM question synthesis failed, using baseline:", e?.message || e);
558
+ }
559
+ return base;
560
+ }
358
561
  };
359
562
 
360
563
  exports.AcademicPaperSchema = AcademicPaperSchema;
361
564
  exports.AcademicSearchEngine = AcademicSearchEngine;
362
565
  exports.ArXivSearchEngine = ArXivSearchEngine;
363
566
  exports.CS2023_KNOWLEDGE_AREAS = CS2023_KNOWLEDGE_AREAS;
567
+ exports.CSTA_K12_STRANDS = CSTA_K12_STRANDS;
364
568
  exports.CitationManager = CitationManager;
365
569
  exports.LiteratureReviewSynthesizer = LiteratureReviewSynthesizer;
366
570
  exports.mapTopicToCS2023 = mapTopicToCS2023;
571
+ exports.reconstructOpenAlexAbstract = reconstructOpenAlexAbstract;
367
572
  //# sourceMappingURL=index.cjs.map
368
573
  //# sourceMappingURL=index.cjs.map