@thanh01.pmt/research-kit 1.0.0 → 1.1.1

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