@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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/evidence/claimVerifier.ts"],"names":[],"mappings":";AA+BA,IAAM,eAAA,uBAAsB,GAAA,CAAI;AAAA,EAC9B,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,MAAA;AAAA,EAAQ,MAAA;AAAA,EAAQ,MAAA;AAAA,EAAQ,MAAA;AAAA,EAAQ,MAAA;AAAA,EAAQ,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,MAAA;AAAA,EAAQ,MAAA;AAAA,EAAQ,KAAA;AAAA,EAC3F,MAAA;AAAA,EAAQ,OAAA;AAAA,EAAS,SAAA;AAAA,EAAW,OAAA;AAAA,EAAS,OAAA;AAAA,EAAS,OAAA;AAAA,EAAS,OAAA;AAAA,EAAS,OAAA;AAAA,EAChE,UAAA;AAAA,EAAO,OAAA;AAAA,EAAS,qBAAA;AAAA,EAAQ,YAAA;AAAA,EAAS,QAAA;AAAA,EAAO,KAAA;AAAA,EAAO,UAAA;AAAA,EAAO,OAAA;AAAA,EAAM,WAAA;AAAA,EAAQ,cAAA;AAAA,EACpE,SAAA;AAAA,EAAM,eAAA;AAAA,EAAO,SAAA;AAAA,EAAM,QAAA;AAAA,EAAO,YAAA;AAAA,EAAM,UAAA;AAAA,EAAO,UAAA;AAAA,EAAO,SAAA;AAAA,EAAM,WAAA;AAAA,EAAQ,YAAA;AAAA,EAAM,IAAA;AAAA,EAAM,QAAA;AAAA,EAAO;AACjF,CAAC,CAAA;AAED,SAAS,yBAAyB,IA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AA,CAAQ,KAAA,EAAO,GAAG,CAAC,CAAA,EAAA;AAAA;AAClI,SACF;AAEA,QAAA,OAAO;AAAA,UACL,oBAAoB,MAAA,CAAO,MAAA;AAAA,UAC3B,oBAAA,EAAsB,cAAA;AAAA,UACtB,kBAAA,EAAoB,YAAA;AAAA,UACpB,qBAAA,EAAuB,eAAA;AAAA,UACvB,iBAAA;AAAA,UACA,aAAA,EAAe,IAAA;AAAA,UACf,MAAA,EAAQ,YAAA;AAAA,UACR,QAAA,EAAU,OAAA,CAAQ,IAAA,CAAK,IAAI;AAAA,SAC7B;AAAA,MACF;AAAA,IACJ,SAAS,CAAA,EAAQ;AACf,MAAA,OAAA,CAAQ,IAAA,CAAK,iGAAA,EAAmG,CAAA,EAAG,OAAA,IAAW,CAAC,CAAA;AAAA,IACjI;AAEA,IAAA,OAAO,SAAA;AAAA,EACT;AACF","file":"chunk-2XIEWCUE.js","sourcesContent":["import { LlmTextFn } from '../config/researchConfig';\n\nexport type ClaimVerdict = 'supported' | 'refuted' | 'not_enough_evidence' | 'lexical_match_only';\n\nexport interface VerifiedClaim {\n claimText: string;\n sourceUrl?: string;\n verdict: ClaimVerdict;\n isSupported: boolean;\n isLlmVerified: boolean;\n confidenceScore: number;\n extractedQuote?: string;\n explanation?: string;\n}\n\nexport interface ClaimSweepReport {\n totalClaimsChecked: number;\n supportedClaimsCount: number;\n refutedClaimsCount: number;\n unverifiedClaimsCount: number;\n hallucinationRisk: 'low' | 'medium' | 'high';\n isLlmVerified: boolean;\n claims: VerifiedClaim[];\n reportMd: string;\n}\n\n/**\n * Non-semantic grammatical fillers ONLY.\n * NEVER include negation words ('không', 'chưa', 'not', 'never') or causal markers ('khi', 'nếu', 'thì', 'if', 'then')\n * because stripping them inverts semantic polarity and destroys conditional assertions.\n */\nconst CLAIM_STOPWORDS = new Set([\n 'the', 'and', 'for', 'with', 'that', 'this', 'from', 'into', 'are', 'was', 'were', 'have', 'has',\n 'will', 'would', 'through', 'their', 'these', 'those', 'which', 'while',\n 'của', 'trong', 'được', 'những', 'các', 'cho', 'với', 'và', 'hoặc', 'để',\n 'từ', 'đến', 'về', 'này', 'đó', 'một', 'như', 'sẽ', 'đang', 'đã', 'ra', 'vào', 'là',\n]);\n\nfunction extractSignificantTokens(text: string): string[] {\n return text\n .normalize('NFC')\n .toLowerCase()\n .replace(/[.,;:!?()[\\]{}\"“”‘’/\\\\|`*_~#-]+/g, ' ')\n .split(/\\s+/)\n .filter((w) => w.length >= 3 && !CLAIM_STOPWORDS.has(w));\n}\n\nfunction tokenMatchesCorpus(token: string, lowerCorpus: string): boolean {\n if (lowerCorpus.includes(token)) return true;\n // Basic morphological stem check (e.g., eliminate -> eliminat, isolation -> isolat, races -> race)\n if (token.length >= 6) {\n const stem = token.replace(/(?:ing|tion|ions|ment|ments|ed|es|s)$/, '');\n if (stem.length >= 4 && lowerCorpus.includes(stem)) return true;\n }\n return false;\n}\n\n/**\n * Claim-Support Sweep & Fact Checker\n * Combines Deterministic Passage Retrieval (Passage Candidate Slicing)\n * with LLM Semantic Entailment (Natural Language Inference).\n */\nexport class ClaimVerifier {\n /**\n * Deterministic lexical match baseline.\n * Explicitly marks verdict as 'lexical_match_only' to prevent false sense of semantic verification.\n */\n verifyClaimsDeterministic(claims: string[], sourceCorpus: string): ClaimSweepReport {\n const verifiedList: VerifiedClaim[] = [];\n const normCorpus = sourceCorpus.normalize('NFC');\n const lowerCorpus = normCorpus.toLowerCase();\n const corpusSentences = normCorpus\n .split(/(?<=[.!?。\\n])\\s+/)\n .map((s) => s.replace(/^[-*•#>\\s]+/, '').replace(/\\s+/g, ' ').trim())\n .filter((s) => {\n if (s.length < 25) return false;\n if (/^(title:|url source:|final url:|http|!\\[)/i.test(s)) return false;\n return true;\n });\n\n for (const claim of claims) {\n const claimTokens = extractSignificantTokens(claim);\n const matchCount = claimTokens.filter((t) => tokenMatchesCorpus(t, lowerCorpus)).length;\n const matchRatio = claimTokens.length > 0 ? matchCount / claimTokens.length : 0;\n\n // Find best candidate supporting quote from corpus sentences via lexical overlap\n let bestQuote: string | undefined;\n let bestSentenceRatio = 0;\n for (const sent of corpusSentences) {\n const lowerSent = sent.toLowerCase();\n const sentMatches = claimTokens.filter((t) => tokenMatchesCorpus(t, lowerSent)).length;\n const sentRatio = claimTokens.length > 0 ? sentMatches / claimTokens.length : 0;\n if (sentRatio > bestSentenceRatio) {\n bestSentenceRatio = sentRatio;\n bestQuote = sent.slice(0, 240);\n }\n }\n\n const effectiveRatio = Math.max(matchRatio, bestSentenceRatio);\n const hasLexicalEvidence = effectiveRatio >= 0.55;\n\n verifiedList.push({\n claimText: claim,\n verdict: 'lexical_match_only',\n isSupported: hasLexicalEvidence,\n isLlmVerified: false,\n confidenceScore: Math.round(effectiveRatio * 100),\n extractedQuote: hasLexicalEvidence ? bestQuote : undefined,\n explanation: hasLexicalEvidence\n ? `Lexical token match found (${Math.round(effectiveRatio * 100)}% token overlap). Semantic entailment requires LLM verification.`\n : `Insufficient lexical overlap in harvest corpus (${Math.round(effectiveRatio * 100)}%).`,\n });\n }\n\n const supportedCount = verifiedList.filter((c) => c.isSupported).length;\n const supportPct = claims.length > 0 ? (supportedCount / claims.length) * 100 : 100;\n const hallucinationRisk = supportPct >= 80 ? 'low' : supportPct >= 50 ? 'medium' : 'high';\n\n const mdLines = [\n `# 🔍 Claim-Support Sweep & Verification Report (Lexical Scan Mode)`,\n `> **Notice:** *Scored via deterministic lexical token matching. True semantic entailment requires an LLM call.*`,\n `> **Lexical Coverage:** \\`${supportPct.toFixed(1)}%\\` (${supportedCount}/${claims.length} claims with token matches) | **Hallucination Risk (Lexical):** \\`${hallucinationRisk.toUpperCase()}\\``,\n `\\n| Pedagogical / Technical Claim | Evidence Status | Token Match | Supporting Quote | Semantic Status |`,\n `|---|---|---|---|---|`,\n ...verifiedList.map(\n (c) =>\n `| ${c.claimText.replace(/\\|/g, '/')} | ${c.isSupported ? '🟡 **LEXICAL MATCH**' : '⚠️ *UNVERIFIED / GAP*'} | \\`${c.confidenceScore}%\\` | ${(c.extractedQuote || '—').replace(/\\|/g, '/')} | *Awaiting LLM Entailment* |`\n ),\n ];\n\n return {\n totalClaimsChecked: claims.length,\n supportedClaimsCount: supportedCount,\n refutedClaimsCount: 0,\n unverifiedClaimsCount: claims.length - supportedCount,\n hallucinationRisk,\n isLlmVerified: false,\n claims: verifiedList,\n reportMd: mdLines.join('\\n'),\n };\n }\n\n /**\n * Primary verification interface.\n * If an LLM callback is provided, performs genuine Semantic Entailment (NLI).\n * Otherwise falls back to deterministic lexical retrieval with honest labeling.\n */\n async verifyClaims(\n claims: string[],\n sourceCorpus: string,\n options: { llm?: LlmTextFn } = {}\n ): Promise<ClaimSweepReport> {\n const detReport = this.verifyClaimsDeterministic(claims, sourceCorpus);\n if (!options.llm || claims.length === 0) {\n return detReport;\n }\n\n try {\n const normCorpus = sourceCorpus.normalize('NFC');\n const cleanSubstantiveText = normCorpus\n .replace(/```[\\s\\S]*?```/g, '\\n')\n .split('\\n')\n .filter((l) => !/^(title:|url source:|final url:|http|!\\[|#)/i.test(l.trim()))\n .join('\\n')\n .trim();\n\n const corpusSentences = cleanSubstantiveText\n .split(/(?<=[.!?。\\n])\\s+/)\n .map((s) => s.replace(/^[-*•#>\\s]+/, '').replace(/\\s+/g, ' ').trim())\n .filter((s) => s.length >= 25 && !/^(cookie|privacy|sign in|all rights reserved)/i.test(s));\n\n // Collect candidate passages for each claim.\n // If cross-lingual (e.g. Vietnamese claim vs English corpus), lexical overlap alone might miss translated synonyms,\n // so we include top lexical matches AND the first substantive paragraphs of the reference document.\n const fallbackExcerpts = corpusSentences.slice(0, 8).join('\\n');\n\n const claimContexts = claims.map((claim, idx) => {\n const tokens = extractSignificantTokens(claim);\n const topSentences = corpusSentences\n .map((sent) => ({\n sent,\n overlap: tokens.filter((t) => tokenMatchesCorpus(t, sent.toLowerCase())).length,\n }))\n .filter((item) => item.overlap > 0)\n .sort((a, b) => b.overlap - a.overlap)\n .slice(0, 5)\n .map((item) => item.sent);\n\n const candidates = topSentences.length > 0\n ? `${topSentences.join('\\n')}\\n\\n[General Reference Excerpts]:\\n${fallbackExcerpts}`\n : fallbackExcerpts || 'No substantive text found.';\n\n return {\n idx,\n claim,\n candidatePassages: candidates,\n };\n });\n\n const prompt = [\n `You are a Rigorous Scientific & Pedagogical Fact-Checking System (Natural Language Inference).`,\n `Evaluate whether each technical/pedagogical claim is strictly SUPPORTED, directly REFUTED, or has NOT_ENOUGH_EVIDENCE in the harvested technical reference text.`,\n `Pay careful attention to NEGATION words (\"không\", \"never\", \"tránh\", \"do not\"), causal relationships, hardware pin constraints, and edge cases. Do not assume truth without textual evidence.`,\n `\\nHarvested Reference Excerpts for Claims:\\n`,\n claimContexts.map((c) => `[Claim ${c.idx + 1}]: \"${c.claim}\"\\n[Passage Candidates]: ${c.candidatePassages}`).join('\\n\\n'),\n `\\nReturn ONLY a valid JSON array of objects with the exact structure:`,\n `[{\"claimIndex\": 1, \"verdict\": \"supported\"|\"refuted\"|\"not_enough_evidence\", \"confidenceScore\": 95, \"extractedQuote\": \"exact quote from passage\", \"explanation\": \"1-sentence semantic reason\"}]`,\n ].join('\\n');\n\n const raw = await options.llm(prompt, {\n system: 'You are an exacting academic fact-checker. Output strictly valid JSON array without commentary.',\n temperature: 0.1,\n jsonMode: true,\n });\n\n let parsed: any[] = [];\n const arrayMatch = raw.match(/\\[[\\s\\S]*\\]/);\n if (arrayMatch) {\n try {\n const res = JSON.parse(arrayMatch[0]);\n if (Array.isArray(res)) parsed = res;\n } catch {}\n }\n if (parsed.length === 0) {\n const objMatch = raw.match(/\\{[\\s\\S]*\\}/);\n if (objMatch) {\n try {\n const obj = JSON.parse(objMatch[0]);\n const candidateList = obj.claims || obj.results || obj.verifications || Object.values(obj).find(Array.isArray);\n if (Array.isArray(candidateList)) parsed = candidateList;\n } catch {}\n }\n }\n\n if (parsed.length > 0) {\n const verifiedList: VerifiedClaim[] = claims.map((claim, idx) => {\n const item = parsed.find((p: any) => p.claimIndex === idx + 1) || parsed[idx];\n const verdict: ClaimVerdict =\n item && ['supported', 'refuted', 'not_enough_evidence'].includes(item.verdict)\n ? item.verdict\n : detReport.claims[idx]?.isSupported\n ? 'supported'\n : 'not_enough_evidence';\n\n const isSupported = verdict === 'supported';\n return {\n claimText: claim,\n verdict,\n isSupported,\n isLlmVerified: true,\n confidenceScore: Number(item?.confidenceScore) || (isSupported ? 90 : 30),\n extractedQuote: item?.extractedQuote || detReport.claims[idx]?.extractedQuote,\n explanation: item?.explanation || (isSupported ? 'Semantically entailed by reference corpus.' : 'Not verified.'),\n };\n });\n\n const supportedCount = verifiedList.filter((c) => c.verdict === 'supported').length;\n const refutedCount = verifiedList.filter((c) => c.verdict === 'refuted').length;\n const unverifiedCount = claims.length - supportedCount;\n const supportPct = claims.length > 0 ? (supportedCount / claims.length) * 100 : 100;\n const hallucinationRisk = refutedCount > 0 ? 'high' : supportPct >= 75 ? 'low' : 'medium';\n\n const mdLines = [\n `# 🔍 Claim-Support Sweep & Semantic Verification Report (LLM NLI Evaluated)`,\n `> **Semantic Verification Rate:** \\`${supportPct.toFixed(1)}%\\` (${supportedCount}/${claims.length} claims supported) | **Refuted / Contradictions:** \\`${refutedCount}\\` | **Hallucination Risk:** \\`${hallucinationRisk.toUpperCase()}\\``,\n `\\n| Pedagogical / Technical Claim | Semantic Verdict | Confidence | Supporting Quote / Evidence | Explanation |`,\n `|---|---|---|---|---|`,\n ...verifiedList.map(\n (c) =>\n `| ${c.claimText.replace(/\\|/g, '/')} | ${\n c.verdict === 'supported'\n ? '✅ **SUPPORTED**'\n : c.verdict === 'refuted'\n ? '❌ **REFUTED**'\n : '⚠️ *NOT ENOUGH EVIDENCE*'\n } | \\`${c.confidenceScore}%\\` | ${(c.extractedQuote || '—').replace(/\\|/g, '/')} | ${(c.explanation || '').replace(/\\|/g, '/')} |`\n ),\n ];\n\n return {\n totalClaimsChecked: claims.length,\n supportedClaimsCount: supportedCount,\n refutedClaimsCount: refutedCount,\n unverifiedClaimsCount: unverifiedCount,\n hallucinationRisk,\n isLlmVerified: true,\n claims: verifiedList,\n reportMd: mdLines.join('\\n'),\n };\n }\n } catch (e: any) {\n console.warn('[ClaimVerifier] LLM semantic verification failed, falling back to deterministic lexical report:', e?.message || e);\n }\n\n return detReport;\n }\n}\n"]}
@@ -0,0 +1,514 @@
1
+ import { AcademicSearchEngine, LiteratureReviewSynthesizer, mapTopicToCS2023 } from './chunk-DOXSPRSP.js';
2
+ import { inferPrimaryCodeLanguage, MultiSourceSearchEngine, HealthAuditor, CatalogBuilder, PedagogicalTermExtractor, classifyTechnicalDomain } from './chunk-XIF5YNI7.js';
3
+ import { EvidenceScorer, ProvenanceTracker } from './chunk-GKF3NDEX.js';
4
+ import { WebScraper } from './chunk-KAFQVI2R.js';
5
+
6
+ // src/pipeline/campaignPlanner.ts
7
+ var CampaignPlanner = class {
8
+ createPlan(topic, domain, options = {}) {
9
+ const slug = topic.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "research-topic";
10
+ const scaleMode = options.isDeep ? "deep" : domain === "academic" ? "academic_survey" : "direct";
11
+ const maxRounds = options.maxRounds ?? (scaleMode === "deep" ? 3 : 1);
12
+ const ctx = options.context;
13
+ const toolAnchor = [ctx?.hardwarePlatform, ctx?.softwareEnv].filter(Boolean).join(" ").trim();
14
+ const coreSubject = toolAnchor ? `${toolAnchor} ${topic}` : topic;
15
+ const plannedQueries = [];
16
+ if (ctx && (ctx.hardwarePlatform || ctx.softwareEnv || ctx.inScopeTopics && ctx.inScopeTopics.length > 0)) {
17
+ plannedQueries.push(
18
+ `${toolAnchor || topic} official documentation getting started guide ${ctx.inScopeTopics?.slice(0, 2).join(" ") || ""}`.trim()
19
+ );
20
+ const ageHint = ctx.ageBand ? `ages ${ctx.ageBand[0]}-${ctx.ageBand[1]}` : "beginner project";
21
+ plannedQueries.push(
22
+ `${toolAnchor || topic} hands-on project tutorial curriculum ${ageHint}`.trim()
23
+ );
24
+ plannedQueries.push(
25
+ `${toolAnchor || topic} common mistakes pitfalls debugging troubleshooting`.trim()
26
+ );
27
+ } else {
28
+ plannedQueries.push(
29
+ `${coreSubject} official documentation getting started`,
30
+ `${coreSubject} architecture design best practices`,
31
+ `${coreSubject} practical code examples and pitfalls`
32
+ );
33
+ }
34
+ if (domain === "hardware") {
35
+ plannedQueries.push(`${ctx?.hardwarePlatform || topic} pinout schematic sensor wiring specifications`);
36
+ } else if (domain === "academic") {
37
+ plannedQueries.push(`${topic} state of the art benchmarks survey paper`);
38
+ }
39
+ const mdLines = [
40
+ `# \u{1F5FA}\uFE0F Master Research Plan: ${topic}`,
41
+ `> **Slug:** \`${slug}\` | **Domain:** \`${domain.toUpperCase()}\` | **Scale Mode:** \`${scaleMode.toUpperCase()}\` | **Max Rounds:** \`${maxRounds}\``,
42
+ `
43
+ ## 1. Campaign Objective`,
44
+ `- Exhaustively harvest and verify Technical & Pedagogical Ground Truth for **${topic}** to anchor all downstream SOT artifacts in Curriculum OS.`,
45
+ `
46
+ ## 2. Planned Multi-Source Queries`,
47
+ ...plannedQueries.map((q, i) => `${i + 1}. \`${q}\``),
48
+ `
49
+ ## 3. Acceptance Criteria & Quality Gates`,
50
+ `- Minimum 3 primary technical resources with Relevancy Score >= 6/10.`,
51
+ `- Extract verified code blocks, reference tables, and bilingual domain concepts.`,
52
+ `- Produce the complete 3-layer catalog: \`RESOURCE_INDEX.json\`, \`RESOURCE_CATALOG.md\`, and \`KNOWLEDGE_GRAPH.md\`.`
53
+ ];
54
+ return {
55
+ topic,
56
+ slug,
57
+ domain,
58
+ scaleMode,
59
+ plannedQueries,
60
+ maxRounds,
61
+ planMd: mdLines.join("\n")
62
+ };
63
+ }
64
+ /**
65
+ * Optional LLM-augmented query planner when the host app provides an `llm` callback.
66
+ */
67
+ async createPlanWithLlm(topic, domain, options = {}) {
68
+ const basePlan = this.createPlan(topic, domain, options);
69
+ if (!options.llm) return basePlan;
70
+ try {
71
+ const ctx = options.context;
72
+ const prompt = [
73
+ `Generate 4 high-precision search engine queries (in English or bilingual as best suited for technical documentation and curriculum discovery) for researching this course:`,
74
+ `- Topic / Title: ${topic}`,
75
+ ctx?.positioning ? `- Positioning: ${ctx.positioning}` : "",
76
+ ctx?.hardwarePlatform ? `- Hardware Platform: ${ctx.hardwarePlatform}` : "",
77
+ ctx?.softwareEnv ? `- Software / Tools: ${ctx.softwareEnv}` : "",
78
+ ctx?.ageBand ? `- Learner Age Band: ${ctx.ageBand[0]}-${ctx.ageBand[1]}` : "",
79
+ ctx?.inScopeTopics?.length ? `- In-Scope Topics: ${ctx.inScopeTopics.join(", ")}` : "",
80
+ `The 4 queries must cover: (1) Official technical/API/hardware documentation, (2) Real-world project/course exemplars for this age group, (3) Common beginner misconceptions & debugging pitfalls, (4) Best pedagogical scaffolding practices.`,
81
+ `Return ONLY a JSON array of 4 query strings: ["query 1", "query 2", "query 3", "query 4"]`
82
+ ].filter(Boolean).join("\n");
83
+ const raw = await options.llm(prompt, {
84
+ system: "You are a technical research librarian. Return only a valid JSON array of 4 search query strings.",
85
+ temperature: 0.2,
86
+ jsonMode: true
87
+ });
88
+ const match = raw.match(/\[[\s\S]*\]/);
89
+ if (match) {
90
+ const parsed = JSON.parse(match[0]);
91
+ if (Array.isArray(parsed) && parsed.length >= 2) {
92
+ const queries = parsed.map((q) => String(q).trim()).filter((q) => q.length > 4).slice(0, 5);
93
+ if (queries.length >= 2) {
94
+ basePlan.plannedQueries = queries;
95
+ }
96
+ }
97
+ }
98
+ } catch (e) {
99
+ console.warn("[CampaignPlanner] LLM query expansion failed, using deterministic queries:", e?.message || e);
100
+ }
101
+ return basePlan;
102
+ }
103
+ };
104
+
105
+ // src/pipeline/referencePackBuilder.ts
106
+ var ReferencePackBuilder = class {
107
+ buildReferencePack(topic, domain, options = {}) {
108
+ const registry = [];
109
+ const defaultLang = inferPrimaryCodeLanguage(topic, options.context, domain);
110
+ if (options.academicPapers) {
111
+ options.academicPapers.forEach((p, idx) => {
112
+ const takeaway = p.tldr?.trim() || (p.abstract ? p.abstract.slice(0, 220).trim() : `Peer-reviewed publication (${p.year || "n.d."}, ${p.citationCount} citations).`);
113
+ registry.push({
114
+ id: `REF-ACAD-${String(idx + 1).padStart(2, "0")}`,
115
+ title: p.title,
116
+ sourceType: "academic_paper",
117
+ url: p.url || (p.doi ? `https://doi.org/${p.doi}` : ""),
118
+ relevanceScore: 9,
119
+ extractedKeyTakeaways: [takeaway]
120
+ });
121
+ });
122
+ }
123
+ if (options.scrapedDocs) {
124
+ options.scrapedDocs.forEach((d, idx) => {
125
+ const takeaways = d.keyTakeaways && d.keyTakeaways.length > 0 ? d.keyTakeaways : d.doc.keyExcerpts && d.doc.keyExcerpts.length > 0 ? d.doc.keyExcerpts.slice(0, 3) : [d.summary];
126
+ registry.push({
127
+ id: `REF-DOC-${String(idx + 1).padStart(2, "0")}`,
128
+ title: d.doc.title,
129
+ sourceType: d.doc.fetchProvider === "youtube" ? "video_transcript" : "official_docs",
130
+ url: d.doc.url,
131
+ relevanceScore: d.score,
132
+ extractedKeyTakeaways: takeaways
133
+ });
134
+ });
135
+ }
136
+ const referenceRegistryJson = JSON.stringify(
137
+ {
138
+ topic,
139
+ domain,
140
+ generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
141
+ totalReferences: registry.length,
142
+ cs2023StandardArea: options.cs2023Area?.code || "SDF",
143
+ cstaK12Strand: options.k12Strand?.code || "AP",
144
+ synthesizedInsights: options.synthesizedInsights,
145
+ concepts: options.concepts || [],
146
+ registry
147
+ },
148
+ null,
149
+ 2
150
+ );
151
+ const codeBlocks = options.scrapedDocs?.flatMap((d) => {
152
+ if (d.doc.extractedCodeBlocks && d.doc.extractedCodeBlocks.length > 0) {
153
+ return d.doc.extractedCodeBlocks.slice(0, 2).map((b) => `\`\`\`${b.language || defaultLang}
154
+ ${b.code}
155
+ \`\`\``);
156
+ }
157
+ return d.doc.extractedCodeSnippets.slice(0, 2).map((c) => `\`\`\`${defaultLang}
158
+ ${c}
159
+ \`\`\``);
160
+ }) || [];
161
+ const insightsSection = [];
162
+ if (options.synthesizedInsights) {
163
+ if (options.synthesizedInsights.executiveSummary) {
164
+ insightsSection.push(`
165
+ ### Synthesized Executive Summary
166
+ ${options.synthesizedInsights.executiveSummary}`);
167
+ }
168
+ if (options.synthesizedInsights.keyTakeaways?.length > 0) {
169
+ insightsSection.push(
170
+ `
171
+ ### Key Technical & Pedagogical Takeaways
172
+ ` + options.synthesizedInsights.keyTakeaways.map((t) => `- ${t}`).join("\n")
173
+ );
174
+ }
175
+ if (options.synthesizedInsights.commonMisconceptionsAndPitfalls?.length > 0) {
176
+ insightsSection.push(
177
+ `
178
+ ### Documented Learner Misconceptions & Debugging Pitfalls
179
+ ` + options.synthesizedInsights.commonMisconceptionsAndPitfalls.map((m) => `- ${m}`).join("\n")
180
+ );
181
+ }
182
+ if (options.synthesizedInsights.recommendedExemplars?.length > 0) {
183
+ insightsSection.push(
184
+ `
185
+ ### Reference Project & Curriculum Exemplars
186
+ ` + options.synthesizedInsights.recommendedExemplars.map((e) => `- ${e}`).join("\n")
187
+ );
188
+ }
189
+ } else if (registry.length > 0) {
190
+ const topTakeaways = registry.flatMap((r) => r.extractedKeyTakeaways.slice(0, 2).map((t) => `- **[${r.id}]** ${t}`));
191
+ if (topTakeaways.length > 0) {
192
+ insightsSection.push(`
193
+ ### Extracted Source Takeaways
194
+ ` + topTakeaways.join("\n"));
195
+ }
196
+ }
197
+ const mdLines = [
198
+ `# \u{1F4DA} REFERENCE_PACK.md: ${topic}`,
199
+ `> **Domain:** \`${domain.toUpperCase()}\` | **CS2023 Area:** \`${options.cs2023Area?.code || "SE"}\` \u2014 *${options.cs2023Area?.name || "Software Engineering"}*${options.k12Strand ? ` | **CSTA K-12:** \`${options.k12Strand.code}\` (${options.k12Strand.name})` : ""}`,
200
+ `> **Curriculum OS Status:** \`<!-- [SME_APPROVED] -->\``,
201
+ `
202
+ ## 1. Executive Summary & Ground Truth Mandate`,
203
+ `This reference pack serves as the immutable ground truth for all downstream lesson plans, code labs, and rubrics for **${topic}**.`,
204
+ ...insightsSection,
205
+ `
206
+ ## 2. Technical Ground Truth Registry`,
207
+ `| Reference ID | Type | Title | Relevance | Source Link |`,
208
+ `|---|---|---|---|---|`,
209
+ ...registry.map(
210
+ (r) => `| **${r.id}** | \`${r.sourceType}\` | ${r.title.replace(/\|/g, "/")} | \u2B50 \`${r.relevanceScore}/10\` | [Access](${r.url}) |`
211
+ ),
212
+ `
213
+ ## 3. Extracted Code Signatures & Primitives`,
214
+ ...codeBlocks.length > 0 ? codeBlocks : ["*No explicit code signatures captured.*"],
215
+ `
216
+ ## 4. Academic Alignment & Standard Citations`,
217
+ `- Aligns directly with IEEE/ACM Computer Science Curricula (${options.cs2023Area?.code || "SDF"}) and CSTA K-12 (${options.k12Strand?.code || "AP"}) standards.`,
218
+ `- All claims and code examples are anchored to physical primary sources listed in the registry above.`
219
+ ];
220
+ return {
221
+ referenceRegistryJson,
222
+ referencePackMd: mdLines.join("\n")
223
+ };
224
+ }
225
+ };
226
+
227
+ // src/pipeline/harvestPipeline.ts
228
+ function normalizeUrlForDedup(rawUrl) {
229
+ try {
230
+ const u = new URL(rawUrl.trim());
231
+ u.hash = "";
232
+ for (const key of [...u.searchParams.keys()]) {
233
+ if (/^(utm_|fbclid$|gclid$|ref$|source$)/i.test(key)) {
234
+ u.searchParams.delete(key);
235
+ }
236
+ }
237
+ const path = u.pathname.replace(/\/+$/, "") || "/";
238
+ const query = u.searchParams.toString();
239
+ return `${u.protocol}//${u.hostname.toLowerCase()}${path}${query ? `?${query}` : ""}`;
240
+ } catch {
241
+ return rawUrl.trim().toLowerCase().replace(/\/+$/, "");
242
+ }
243
+ }
244
+ var HarvestPipeline = class {
245
+ searchEngine;
246
+ scraper;
247
+ auditor;
248
+ scorer;
249
+ catalogBuilder;
250
+ provenanceTracker;
251
+ academicSearch;
252
+ litReviewSynthesizer;
253
+ planner;
254
+ refPackBuilder;
255
+ termExtractor;
256
+ customSynthesizer;
257
+ defaultLlm;
258
+ constructor(options = {}) {
259
+ const allowEnv = options.allowEnvFallback ?? true;
260
+ const keys = {
261
+ tavily: options.apiKeys?.tavily || options.tavilyKey,
262
+ exa: options.apiKeys?.exa || options.exaKey,
263
+ jina: options.apiKeys?.jina || options.jinaKey,
264
+ serper: options.apiKeys?.serper || options.serperKey,
265
+ semanticScholar: options.apiKeys?.semanticScholar || options.semanticScholarKey
266
+ };
267
+ this.searchEngine = new MultiSourceSearchEngine({
268
+ apiKeys: keys,
269
+ allowEnvFallback: allowEnv,
270
+ customAdapter: options.customSearchAdapter
271
+ });
272
+ this.scraper = new WebScraper({
273
+ crawl4aiHost: options.crawl4aiHost,
274
+ jinaKey: keys.jina,
275
+ allowEnvFallback: allowEnv,
276
+ customAdapter: options.customCrawlerAdapter
277
+ });
278
+ this.auditor = new HealthAuditor();
279
+ this.scorer = new EvidenceScorer();
280
+ this.catalogBuilder = new CatalogBuilder();
281
+ this.provenanceTracker = new ProvenanceTracker();
282
+ this.academicSearch = new AcademicSearchEngine({
283
+ apiKey: keys.semanticScholar,
284
+ allowEnvFallback: allowEnv,
285
+ customAdapter: options.customAcademicSearchAdapter
286
+ });
287
+ this.litReviewSynthesizer = new LiteratureReviewSynthesizer();
288
+ this.planner = new CampaignPlanner();
289
+ this.refPackBuilder = new ReferencePackBuilder();
290
+ this.termExtractor = new PedagogicalTermExtractor();
291
+ this.customSynthesizer = options.customSynthesizerAdapter;
292
+ this.defaultLlm = options.llm;
293
+ }
294
+ async run(topic, options = {}) {
295
+ const notify = options.onProgress || (() => {
296
+ });
297
+ const llm = options.llm || this.defaultLlm;
298
+ const synthesizer = options.customSynthesizerAdapter || this.customSynthesizer;
299
+ const mergedKeys = {
300
+ tavily: options.apiKeys?.tavily || options.tavilyKey,
301
+ exa: options.apiKeys?.exa || options.exaKey,
302
+ jina: options.apiKeys?.jina || options.jinaKey,
303
+ serper: options.apiKeys?.serper || options.serperKey,
304
+ semanticScholar: options.apiKeys?.semanticScholar || options.semanticScholarKey
305
+ };
306
+ if (options.customSearchAdapter) {
307
+ this.searchEngine.setCustomAdapter(options.customSearchAdapter);
308
+ }
309
+ if (options.customCrawlerAdapter) {
310
+ this.scraper.setCustomAdapter(options.customCrawlerAdapter);
311
+ }
312
+ if (options.customAcademicSearchAdapter) {
313
+ this.academicSearch.setCustomAdapter(options.customAcademicSearchAdapter);
314
+ }
315
+ notify("PLANNING", `Classifying domain and creating Master Research Plan for "${topic}"...`);
316
+ const domainResult = classifyTechnicalDomain(topic, options.domain, options.context);
317
+ const domain = domainResult.domain;
318
+ const plan = llm ? await this.planner.createPlanWithLlm(topic, domain, {
319
+ maxRounds: options.maxRounds,
320
+ isDeep: options.isDeep,
321
+ context: options.context,
322
+ llm
323
+ }) : this.planner.createPlan(topic, domain, {
324
+ maxRounds: options.maxRounds,
325
+ isDeep: options.isDeep,
326
+ context: options.context
327
+ });
328
+ notify("ACADEMIC", `Querying academic literature & mapping to IEEE/ACM CS2023 and CSTA K-12 standards...`);
329
+ const taxonomyMatch = mapTopicToCS2023(topic, options.context);
330
+ const papers = await this.academicSearch.searchPapers(topic, {
331
+ limit: 4,
332
+ apiKey: mergedKeys.semanticScholar,
333
+ customAdapter: options.customAcademicSearchAdapter
334
+ });
335
+ const litReview = llm ? await this.litReviewSynthesizer.synthesizeWithLlm(
336
+ topic,
337
+ papers,
338
+ taxonomyMatch.area,
339
+ taxonomyMatch.k12Strand,
340
+ { llm, context: options.context }
341
+ ) : this.litReviewSynthesizer.synthesize(
342
+ topic,
343
+ papers,
344
+ taxonomyMatch.area,
345
+ taxonomyMatch.k12Strand
346
+ );
347
+ notify("DISCOVERY", `Executing multi-source search queries across configured adapters...`);
348
+ const scrapedDocs = [];
349
+ const provenanceRecords = [];
350
+ const visitedUrls = /* @__PURE__ */ new Set();
351
+ for (const query of plan.plannedQueries) {
352
+ notify("SEARCHING", `Searching: ${query}`);
353
+ const hits = await this.searchEngine.search(query, {
354
+ limit: 2,
355
+ apiKeys: mergedKeys,
356
+ customAdapter: options.customSearchAdapter
357
+ });
358
+ for (const hit of hits) {
359
+ if (!hit?.url) continue;
360
+ const normUrl = normalizeUrlForDedup(hit.url);
361
+ if (visitedUrls.has(normUrl)) continue;
362
+ visitedUrls.add(normUrl);
363
+ try {
364
+ notify("SCRAPING", `Extracting clean markdown from: ${hit.url}`);
365
+ const doc = await this.scraper.scrapeUrl(hit.url, {
366
+ customAdapter: options.customCrawlerAdapter,
367
+ jinaKey: mergedKeys.jina
368
+ });
369
+ const audit = this.auditor.auditDocument(doc);
370
+ if (audit.passed) {
371
+ const scored = this.scorer.scoreDocument(doc, domain, topic);
372
+ if (scored.isApproved) {
373
+ scrapedDocs.push({
374
+ doc,
375
+ score: scored.score,
376
+ summary: scored.summary,
377
+ keyTakeaways: scored.keyTakeaways
378
+ });
379
+ provenanceRecords.push({
380
+ resourceId: `RES-${String(scrapedDocs.length).padStart(2, "0")}`,
381
+ sourceUrl: hit.url,
382
+ accessedAt: (/* @__PURE__ */ new Date()).toISOString(),
383
+ domain,
384
+ relevanceScore: scored.score,
385
+ byteSize: doc.byteSize
386
+ });
387
+ }
388
+ }
389
+ } catch (e) {
390
+ console.warn(`Failed to process hit ${hit.url}:`, e?.message || e);
391
+ }
392
+ }
393
+ }
394
+ notify("TERMS", `Extracting bilingual technical concepts and prerequisite DAG...`);
395
+ const docsWithIds = scrapedDocs.map((item, idx) => ({
396
+ resourceId: `RES-${String(idx + 1).padStart(2, "0")}`,
397
+ doc: item.doc
398
+ }));
399
+ const termBundle = await this.termExtractor.extractWithOptionalLlm(topic, domain, docsWithIds, {
400
+ context: options.context,
401
+ llm
402
+ });
403
+ notify("SYNTHESIS", `Synthesizing pedagogical takeaways, misconceptions, and reference pack...`);
404
+ const synthesizedInsights = await this.synthesizeInsights(topic, domain, scrapedDocs, {
405
+ context: options.context,
406
+ llm,
407
+ synthesizer,
408
+ concepts: termBundle.concepts
409
+ });
410
+ notify("CATALOGING", `Compiling Resource Index, Catalog, and Distilled Knowledge Graph...`);
411
+ const catalog = this.catalogBuilder.buildBundle(topic, domain, scrapedDocs, {
412
+ context: options.context,
413
+ concepts: termBundle.concepts,
414
+ conceptDagTsv: termBundle.conceptDagTsv
415
+ });
416
+ const referencePack = this.refPackBuilder.buildReferencePack(topic, domain, {
417
+ cs2023Area: taxonomyMatch.area,
418
+ k12Strand: taxonomyMatch.k12Strand,
419
+ context: options.context,
420
+ scrapedDocs,
421
+ academicPapers: papers,
422
+ concepts: termBundle.concepts,
423
+ synthesizedInsights
424
+ });
425
+ notify("PROVENANCE", `Generating audit trail and provenance sidecar...`);
426
+ const provenance = this.provenanceTracker.generateSidecar(topic, provenanceRecords);
427
+ notify("COMPLETED", `Deep Research & Academic Harvest completed successfully for "${topic}".`);
428
+ return {
429
+ topic,
430
+ domain,
431
+ plan,
432
+ catalog,
433
+ literatureReview: litReview,
434
+ referencePack,
435
+ provenance,
436
+ concepts: termBundle.concepts,
437
+ conceptDagTsv: termBundle.conceptDagTsv,
438
+ synthesizedInsights,
439
+ totalDocumentsScraped: scrapedDocs.length
440
+ };
441
+ }
442
+ async synthesizeInsights(topic, domain, scrapedDocs, options) {
443
+ const excerpts = scrapedDocs.map((d, idx) => ({
444
+ resourceId: `RES-${String(idx + 1).padStart(2, "0")}`,
445
+ title: d.doc.title,
446
+ url: d.doc.url,
447
+ excerpt: d.keyTakeaways.join(" ") || d.summary,
448
+ codeSnippets: d.doc.extractedCodeSnippets.slice(0, 2)
449
+ }));
450
+ if (options.synthesizer) {
451
+ try {
452
+ return await options.synthesizer.synthesize({
453
+ topic,
454
+ domain,
455
+ context: options.context,
456
+ excerpts
457
+ });
458
+ } catch (e) {
459
+ console.warn("[HarvestPipeline] CustomSynthesizerAdapter failed, falling back:", e?.message || e);
460
+ }
461
+ }
462
+ if (options.llm && excerpts.length > 0) {
463
+ try {
464
+ const prompt = [
465
+ `Synthesize pedagogical and technical ground truth for the course topic "${topic}" (Domain: ${domain}).`,
466
+ options.context?.ageBand ? `Target Learner Age Band: ${options.context.ageBand[0]}-${options.context.ageBand[1]}` : "",
467
+ options.context?.hardwarePlatform ? `Hardware Platform: ${options.context.hardwarePlatform}` : "",
468
+ options.context?.softwareEnv ? `Software/Tools: ${options.context.softwareEnv}` : "",
469
+ `
470
+ Verified Harvested Sources:
471
+ ` + excerpts.map((e) => `[${e.resourceId}] ${e.title} (${e.url}): ${e.excerpt}`).join("\n\n"),
472
+ `
473
+ Return ONLY a valid JSON object with this structure:`,
474
+ `{"executiveSummary": "2-3 sentence synthesis anchored to sources", "keyTakeaways": ["[RES-01] ...", "[RES-02] ..."], "commonMisconceptionsAndPitfalls": ["Specific beginner bug or misconception 1", "Misconception 2"], "recommendedExemplars": ["Concrete project/activity exemplar 1", "Exemplar 2"]}`
475
+ ].filter(Boolean).join("\n");
476
+ const raw = await options.llm(prompt, {
477
+ system: "You are a Principal Curriculum Researcher. Output strictly valid JSON grounded in the provided sources.",
478
+ temperature: 0.2,
479
+ jsonMode: true
480
+ });
481
+ const match = raw.match(/\{[\s\S]*\}/);
482
+ if (match) {
483
+ const parsed = JSON.parse(match[0]);
484
+ return {
485
+ executiveSummary: String(parsed.executiveSummary || ""),
486
+ keyTakeaways: Array.isArray(parsed.keyTakeaways) ? parsed.keyTakeaways.map(String) : [],
487
+ commonMisconceptionsAndPitfalls: Array.isArray(parsed.commonMisconceptionsAndPitfalls) ? parsed.commonMisconceptionsAndPitfalls.map(String) : [],
488
+ recommendedExemplars: Array.isArray(parsed.recommendedExemplars) ? parsed.recommendedExemplars.map(String) : [],
489
+ extractedConcepts: options.concepts
490
+ };
491
+ }
492
+ } catch (e) {
493
+ console.warn("[HarvestPipeline] Host LLM synthesis failed, using deterministic synthesis:", e?.message || e);
494
+ }
495
+ }
496
+ const keyTakeaways = excerpts.filter((e) => e.excerpt).slice(0, 6).map((e) => `[${e.resourceId}] ${e.title}: ${e.excerpt}`);
497
+ const pitfalls = scrapedDocs.flatMap(
498
+ (d) => d.doc.markdownContent.split(/(?<=[.!?。\n])\s+/).map((s) => s.trim()).filter(
499
+ (s) => s.length >= 35 && s.length <= 240 && /\b(pitfall|mistake|error|bug|warning|caution|avoid|race condition|deadlock|lỗi|nhầm lẫn|lưu ý|cảnh báo|tránh)\b/i.test(s)
500
+ )
501
+ ).slice(0, 4);
502
+ return {
503
+ executiveSummary: scrapedDocs.length > 0 ? `Synthesized from ${scrapedDocs.length} verified primary sources for "${topic}" (${domain.toUpperCase()}).` : `No external web documents passed quality threshold for "${topic}".`,
504
+ keyTakeaways,
505
+ commonMisconceptionsAndPitfalls: pitfalls,
506
+ recommendedExemplars: scrapedDocs.slice(0, 3).map((d) => `${d.doc.title} (${d.doc.url})`),
507
+ extractedConcepts: options.concepts
508
+ };
509
+ }
510
+ };
511
+
512
+ export { CampaignPlanner, HarvestPipeline, ReferencePackBuilder, normalizeUrlForDedup };
513
+ //# sourceMappingURL=chunk-AUGVVZTL.js.map
514
+ //# sourceMappingURL=chunk-AUGVVZTL.js.map