dsh-ppt 0.34.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.en.md +8 -11
- package/README.md +8 -11
- package/docs/USAGE.en.md +43 -35
- package/docs/USAGE.md +44 -36
- package/docs/VALIDATION.md +4 -0
- package/lib/client.js +1 -1
- package/lib/execution.js +20 -2
- package/lib/tools.js +64 -2
- package/lib/types.d.ts +58 -1
- package/lib/workbench.js +18 -2
- package/package.json +2 -2
- package/skills/dsh-ppt/SKILL.md +34 -32
- package/skills/dsh-ppt/package.json +1 -1
- package/skills/dsh-ppt/references/office-pack.md +124 -0
- package/skills/dsh-ppt/references/research-plan.md +93 -62
- package/skills/dsh-ppt/scripts/build-deck.mjs +60 -2
- package/skills/dsh-ppt/scripts/deck-absorb.mjs +2 -0
- package/skills/dsh-ppt/scripts/deck-advanced.mjs +198 -29
- package/skills/dsh-ppt/scripts/deck-brand-kit.mjs +13 -0
- package/skills/dsh-ppt/scripts/deck-charts-exec.mjs +805 -0
- package/skills/dsh-ppt/scripts/deck-chrome.mjs +10 -1
- package/skills/dsh-ppt/scripts/deck-compose.mjs +386 -0
- package/skills/dsh-ppt/scripts/deck-core.mjs +128 -14
- package/skills/dsh-ppt/scripts/deck-delivery.mjs +141 -3
- package/skills/dsh-ppt/scripts/deck-evidence.mjs +811 -118
- package/skills/dsh-ppt/scripts/deck-export.mjs +652 -0
- package/skills/dsh-ppt/scripts/deck-i18n.mjs +170 -0
- package/skills/dsh-ppt/scripts/deck-layouts.mjs +72 -8
- package/skills/dsh-ppt/scripts/deck-office.mjs +833 -38
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* deck-evidence.mjs ——
|
|
2
|
+
* deck-evidence.mjs —— 权威信源导航、混合资料溯源与 SLOP-13 事实核验引擎。
|
|
3
3
|
*
|
|
4
4
|
* 设计边界:
|
|
5
5
|
* - 100% 离线、零新增运行时依赖、绝不在引擎内部发起网络请求(检索由宿主 Agent / dsh-cite 完成);
|
|
6
|
-
* -
|
|
7
|
-
* 1. `
|
|
8
|
-
* 2.
|
|
9
|
-
* 3.
|
|
10
|
-
*
|
|
11
|
-
* 4. `
|
|
6
|
+
* - 内置 8 大领域权威信源白名单(`AUTHORITATIVE_DOMAINS`)与垃圾/二手转引域名黑名单(`NOISE_DOMAINS`):
|
|
7
|
+
* 1. `detectResearchDomain` + `buildAuthoritativeQueryPack`:按主题自动输出带 `site:` / `filetype:pdf` / `-site:` 排除营销号的精准权威检索式;
|
|
8
|
+
* 2. `classifySourceAuthority`:代码级自动定级 Tier 1/2/3、检测「名义权威机构 + 实际二手转引链接」(`secondary-relay-source`);
|
|
9
|
+
* 3. 完整支持 **Mode C 混合模式**(`origin: 'local-file' | 'web-research'`、`tier: 1 | 2 | 3`、`claimType: 'actual' | 'forecast' | 'policy' | 'benchmark'`):
|
|
10
|
+
* `buildHybridEnrichmentPlan` 诊断本地 Word/Excel/照片已有内容与外部权威对标缺口,输出不冲突的顺延编号 `nextEvidenceId`;
|
|
11
|
+
* 4. `[E1]` / `evidenceIds` 自动注入规范左下角 `source` 脚注、演讲者备注 `notes` 完整溯源卡与封底前 `booktabs` 附录页;
|
|
12
|
+
* 5. `SLOP-13` 升级门禁:拦截悬空引用、空洞假出处、未说明口径的 `unverified`/`conflicting`、把 T3/黑名单自媒体当已核验权威事实、
|
|
13
|
+
* 二手转引冒充一手原链接、预测数据未标预测口径、外源缺失年份及过时基准;并自动尊重 `.dsh-ppt/brand-kit.json` 的 `preferredSources` / `blockedDomains`。
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
16
|
import { stripInlineMarkdown } from './deck-layouts.mjs'
|
|
@@ -18,9 +20,142 @@ import { CURATED_EXEMPLARS, resolveExemplar, matchBestExemplar, getExemplarFewSh
|
|
|
18
20
|
|
|
19
21
|
const MAX_EVIDENCE_ITEMS = 60
|
|
20
22
|
const CONFIDENCE_SET = new Set(['verified', 'estimated', 'conflicting', 'unverified'])
|
|
23
|
+
const ORIGIN_SET = new Set(['local-file', 'web-research'])
|
|
24
|
+
const CLAIM_TYPE_SET = new Set(['actual', 'forecast', 'policy', 'benchmark'])
|
|
21
25
|
const INLINE_REF_RE = /\[([Ee]\d{1,3})\]/g
|
|
22
26
|
const VAGUE_SOURCE_RE = /^(?:(?:数据|资料|信息)?来源\s*[::]\s*|sources?\s*[::]\s*)?(?:网络(?:整理|搜集|公开资料|资料|收集)?|互联网(?:整理|公开资料|资料)?|公开资料(?:整理)?|网上(?:资料|整理)?|综合整理|内部估算|估算|整理自网络|public\s+internet|online\s+sources?|web\s+search|various\s+sources?|internet|google|baidu|ai\s+generated?)[。.\s]*$/i
|
|
23
|
-
const QUANT_LAYOUTS = new Set(['kpi', 'chart', 'chart-split', 'waterfall', 'marimekko', 'tam', 'dumbbell', 'heatmap'])
|
|
27
|
+
const QUANT_LAYOUTS = new Set(['kpi', 'chart', 'chart-split', 'waterfall', 'marimekko', 'tam', 'dumbbell', 'heatmap', 'treemap', 'gauge'])
|
|
28
|
+
const LOCAL_SOURCE_RE = /\.(?:xlsx|xls|csv|tsv|docx|doc|pdf|png|jpe?g|webp|pptx?)(?:\s|$|[))》」】])/i
|
|
29
|
+
const LOCAL_SOURCE_LABEL_RE = /(?:^|[\s((])(?:工作表|本地|内部资料|内部报表|原始台账|Sheet\s*["'])/i
|
|
30
|
+
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// 8-Domain Authoritative Source Knowledge Base & Noise-Domain Blacklist
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
export const AUTHORITATIVE_DOMAINS = Object.freeze({
|
|
36
|
+
'gov-macro': {
|
|
37
|
+
id: 'gov-macro',
|
|
38
|
+
nameZh: '宏观政务与政策规划',
|
|
39
|
+
nameEn: 'Government, Policy & Macro Statistics',
|
|
40
|
+
keywords: /政策|规划|政务|宏观|GDP|十四五|十五五|监管|部委|财政|央行|统计局|国办|低空经济|基础设施|乡村振兴|城镇化|白皮书|regulation|policy|macro|gdp|ministry|government|public sector|fiscal/i,
|
|
41
|
+
tier1Domains: ['gov.cn', 'stats.gov.cn', 'miit.gov.cn', 'ndrc.gov.cn', 'pbc.gov.cn', 'mof.gov.cn', 'worldbank.org', 'imf.org', 'oecd.org'],
|
|
42
|
+
tier2Domains: ['caixin.com', 'reuters.com', 'ft.com', 'economist.com', 'mckinsey.com'],
|
|
43
|
+
tier1LabelsZh: '国家统计局、国务院/工信部/发改委/央行公报、IMF、世界银行、OECD',
|
|
44
|
+
tier1LabelsEn: 'National Bureau of Statistics, Ministries/Central Banks, IMF, World Bank, OECD',
|
|
45
|
+
},
|
|
46
|
+
'finance-filings': {
|
|
47
|
+
id: 'finance-filings',
|
|
48
|
+
nameZh: '金融财报与资本市场',
|
|
49
|
+
nameEn: 'Finance, Earnings & Capital Markets',
|
|
50
|
+
keywords: /财报|年报|季报|营收|毛利|净利|估值|IPO|融资|并购|债券|基金|银行|券商|保险|ARR|EBITDA|earnings|10-k|10-q|annual report|valuation|revenue|margin|banking|fintech|capital market|sec|hkex/i,
|
|
51
|
+
tier1Domains: ['sec.gov', 'hkexnews.hk', 'cninfo.com.cn', 'sse.com.cn', 'szse.cn', 'pbc.gov.cn', 'bis.org', 'federalreserve.gov', 'imf.org'],
|
|
52
|
+
tier2Domains: ['bloomberg.com', 'reuters.com', 'ft.com', 'wsj.com', 'spglobal.com', 'caixin.com', 'mckinsey.com', 'pwc.com', 'deloitte.com'],
|
|
53
|
+
tier1LabelsZh: 'SEC EDGAR、港交所披露易、巨潮资讯/沪深交易所年报、央行/BIS/IMF',
|
|
54
|
+
tier1LabelsEn: 'SEC EDGAR, HKEXnews, CNINFO/Exchange Filings, BIS, Federal Reserve, IMF',
|
|
55
|
+
},
|
|
56
|
+
'ai-tech': {
|
|
57
|
+
id: 'ai-tech',
|
|
58
|
+
nameZh: 'AI、云计算与硬科技',
|
|
59
|
+
nameEn: 'AI, Cloud, SaaS & Deep Tech',
|
|
60
|
+
keywords: /AI|大模型|LLM|Agent|智能体|算力|芯片|半导体|云计算|SaaS|软件|架构|数据库|安全|量子|机器人|自动驾驶|人工智能|artificial intelligence|cloud|semiconductor|chip|gpu|robotics|cybersecurity|software|devtools/i,
|
|
61
|
+
tier1Domains: ['caict.ac.cn', 'miit.gov.cn', 'nist.gov', 'arxiv.org', 'ieee.org', 'acm.org', 'nature.com', 'sec.gov'],
|
|
62
|
+
tier2Domains: ['gartner.com', 'idc.com', 'forrester.com', 'mckinsey.com', 'semi.org', 'yolegroup.com', 'canalys.com', 'counterpointresearch.com'],
|
|
63
|
+
tier1LabelsZh: '中国信通院(CAICT)、工信部、NIST、IEEE/ACM/arXiv、头部厂商财报与官方技术报告',
|
|
64
|
+
tier1LabelsEn: 'NIST, IEEE/ACM/arXiv, CAICT, Listed Tech 10-K Filings, Gartner/IDC/SEMI',
|
|
65
|
+
},
|
|
66
|
+
'medical-clinical': {
|
|
67
|
+
id: 'medical-clinical',
|
|
68
|
+
nameZh: '医疗健康与临床医药',
|
|
69
|
+
nameEn: 'Healthcare, Clinical & Life Sciences',
|
|
70
|
+
keywords: /医疗|医药|临床|患者|医院|新药|生物|基因|肿瘤|疫苗|慢病|医保|器械|FDA|NMPA|clinical|medical|pharma|biotech|patient|hospital|drug|oncology|genome|healthcare|who/i,
|
|
71
|
+
tier1Domains: ['who.int', 'pubmed.ncbi.nlm.nih.gov', 'nih.gov', 'fda.gov', 'nhc.gov.cn', 'nmpa.gov.cn', 'nejm.org', 'thelancet.com', 'nature.com', 'bmj.com'],
|
|
72
|
+
tier2Domains: ['iqvia.com', 'mckinsey.com', 'deloitte.com', 'reuters.com', 'statnews.com'],
|
|
73
|
+
tier1LabelsZh: 'WHO、PubMed/NIH、NEJM/Lancet/BMJ、国家卫健委/NMPA、FDA 官方评审文件',
|
|
74
|
+
tier1LabelsEn: 'WHO, PubMed/NIH, FDA, NEJM, The Lancet, BMJ, National Health Commissions',
|
|
75
|
+
},
|
|
76
|
+
'energy-climate': {
|
|
77
|
+
id: 'energy-climate',
|
|
78
|
+
nameZh: '新能源、双碳与汽车制造',
|
|
79
|
+
nameEn: 'Energy, EV, Battery & Climate',
|
|
80
|
+
keywords: /新能源|电池|固态|锂电|光伏|风电|储能|氢能|碳中和|双碳|ESG|电动车|汽车|智驾|eVTOL|能源|电力|energy|battery|ev|solar|wind|storage|climate|carbon|esg|grid|automotive|mobility/i,
|
|
81
|
+
tier1Domains: ['iea.org', 'irena.org', 'nea.gov.cn', 'miit.gov.cn', 'energy.gov', 'ipcc.ch', 'unep.org'],
|
|
82
|
+
tier2Domains: ['cpcaauto.com', 'caam.org.cn', 'trendforce.com', 'bnef.com', 'woodmac.com', 'spglobal.com', 'reuters.com'],
|
|
83
|
+
tier1LabelsZh: '国际能源署(IEA)、IRENA、国家能源局、工信部、IPCC、中汽协/乘联会',
|
|
84
|
+
tier1LabelsEn: 'IEA, IRENA, DOE, IPCC, National Energy Administrations, BNEF/TrendForce',
|
|
85
|
+
},
|
|
86
|
+
'academic-science': {
|
|
87
|
+
id: 'academic-science',
|
|
88
|
+
nameZh: '学术科研与工程基准',
|
|
89
|
+
nameEn: 'Academic Research & Peer-Reviewed Science',
|
|
90
|
+
keywords: /论文|实验|答辩|基准|算法|模型训练|消融|综述|研究|科学|物理|化学|材料|定理|paper|thesis|defense|benchmark|ablation|survey|peer-reviewed|experiment|research|science|university/i,
|
|
91
|
+
tier1Domains: ['nature.com', 'science.org', 'arxiv.org', 'ieee.org', 'acm.org', 'springer.com', 'sciencedirect.com', 'pnas.org', 'pubmed.ncbi.nlm.nih.gov'],
|
|
92
|
+
tier2Domains: ['mit.edu', 'stanford.edu', 'edu.cn', 'iso.org'],
|
|
93
|
+
tier1LabelsZh: 'Nature、Science、IEEE、ACM、arXiv、Springer/Elsevier 顶刊与高校实验室',
|
|
94
|
+
tier1LabelsEn: 'Nature, Science, IEEE, ACM, arXiv, Springer, ScienceDirect, Top University Labs',
|
|
95
|
+
},
|
|
96
|
+
'consumer-retail': {
|
|
97
|
+
id: 'consumer-retail',
|
|
98
|
+
nameZh: '消费零售、品牌与电商',
|
|
99
|
+
nameEn: 'Consumer, Retail, Brand & E-Commerce',
|
|
100
|
+
keywords: /消费|零售|电商|品牌|出海|渠道|GMV|复购|客单价|快消|餐饮|文旅|社媒|营销|retail|consumer|ecommerce|brand|gmv|omnichannel|fmcg|marketing|dtc/i,
|
|
101
|
+
tier1Domains: ['stats.gov.cn', 'mofcom.gov.cn', 'census.gov', 'sec.gov', 'hkexnews.hk', 'cninfo.com.cn'],
|
|
102
|
+
tier2Domains: ['nielseniq.com', 'kantar.com', 'euromonitor.com', 'mckinsey.com', 'bain.com', 'bcg.com', 'statista.com', 'questmobile.com.cn'],
|
|
103
|
+
tier1LabelsZh: '国家统计局/商务部社零数据、美国普查局、龙头零售上市财报、尼尔森/凯度/欧睿',
|
|
104
|
+
tier1LabelsEn: 'Census/Commerce Retail Data, Listed Retailer Filings, NielsenIQ, Kantar, Euromonitor',
|
|
105
|
+
},
|
|
106
|
+
'general-business': {
|
|
107
|
+
id: 'general-business',
|
|
108
|
+
nameZh: '商业战略与行业研究',
|
|
109
|
+
nameEn: 'Enterprise Strategy & Industry Benchmarks',
|
|
110
|
+
keywords: /.*/,
|
|
111
|
+
tier1Domains: ['stats.gov.cn', 'gov.cn', 'sec.gov', 'hkexnews.hk', 'cninfo.com.cn', 'worldbank.org', 'oecd.org', 'imf.org'],
|
|
112
|
+
tier2Domains: ['mckinsey.com', 'bcg.com', 'bain.com', 'gartner.com', 'idc.com', 'pwc.com', 'deloitte.com', 'reuters.com', 'ft.com', 'caixin.com'],
|
|
113
|
+
tier1LabelsZh: '政府统计公报、上市公司年报、IMF/世界银行/OECD、麦肯锡/BCG/Gartner/IDC',
|
|
114
|
+
tier1LabelsEn: 'Official Statistics, Listed Filings, IMF/World Bank/OECD, McKinsey/BCG/Gartner/IDC',
|
|
115
|
+
},
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
export const NOISE_DOMAINS = Object.freeze([
|
|
119
|
+
'baijiahao.baidu.com',
|
|
120
|
+
'sohu.com',
|
|
121
|
+
'163.com',
|
|
122
|
+
'sina.com.cn',
|
|
123
|
+
'zhihu.com',
|
|
124
|
+
'csdn.net',
|
|
125
|
+
'toutiao.com',
|
|
126
|
+
'mp.weixin.qq.com',
|
|
127
|
+
'medium.com',
|
|
128
|
+
'reddit.com',
|
|
129
|
+
'quora.com',
|
|
130
|
+
'jianshu.com',
|
|
131
|
+
'bilibili.com',
|
|
132
|
+
'douyin.com',
|
|
133
|
+
'xiaohongshu.com',
|
|
134
|
+
'weibo.com',
|
|
135
|
+
'xueqiu.com',
|
|
136
|
+
'tieba.baidu.com',
|
|
137
|
+
'blogspot.com',
|
|
138
|
+
'wordpress.com',
|
|
139
|
+
'36kr.com',
|
|
140
|
+
'huxiu.com',
|
|
141
|
+
'tmtpost.com',
|
|
142
|
+
'cyzone.cn',
|
|
143
|
+
'eastmoney.com',
|
|
144
|
+
])
|
|
145
|
+
|
|
146
|
+
const ALL_TIER1_DOMAINS = new Set([
|
|
147
|
+
...Object.values(AUTHORITATIVE_DOMAINS).flatMap((d) => d.tier1Domains),
|
|
148
|
+
'gov', 'gov.cn', 'edu', 'edu.cn', 'ac.uk', 'ac.cn', 'europa.eu', 'un.org', 'iso.org', 'wto.org', 'ecb.europa.eu', 'cdc.gov', 'ema.europa.eu', 'csrc.gov.cn', 'cbirc.gov.cn', 'samr.gov.cn',
|
|
149
|
+
])
|
|
150
|
+
|
|
151
|
+
const ALL_TIER2_DOMAINS = new Set([
|
|
152
|
+
...Object.values(AUTHORITATIVE_DOMAINS).flatMap((d) => d.tier2Domains),
|
|
153
|
+
'ey.com', 'kpmg.com', 'moodys.com', 'fitchratings.com', 'pitchbook.com', 'cbinsights.com', 'iresearch.cn', 'gg-lb.com', 'gaogong123.com',
|
|
154
|
+
])
|
|
155
|
+
|
|
156
|
+
const TIER1_PUBLISHER_RE = /(?:国家统计局|国务院|工信部|发改委|人民银行|央行|财政部|商务部|卫健委|药监局|能源局|证监会|交易所|信通院|CAICT|SEC|EDGAR|HKEX|港交所|巨潮|年报|季报|10-K|10-Q|财报|WHO|IEA|IRENA|IMF|World\s*Bank|世界银行|OECD|IPCC|NIST|FDA|NMPA|EMA|ISO|Nature|Science|NEJM|Lancet|BMJ|IEEE|ACM|PubMed|NIH|arXiv)/i
|
|
157
|
+
const TIER2_PUBLISHER_RE = /(?:Gartner|IDC|Forrester|McKinsey|麦肯锡|BCG|波士顿咨询|Bain|贝恩|PwC|普华永道|Deloitte|德勤|EY|安永|KPMG|毕马威|Bloomberg|彭博|Reuters|路透|Financial\s*Times|FT|WSJ|Economist|财新|Caixin|TrendForce|集邦|GGII|高工|艾瑞|iResearch|QuestMobile|Canalys|Counterpoint|Nielsen|尼尔森|Kantar|凯度|Euromonitor|欧睿|Statista|SEMI|Yole|中汽协|乘联会|CPCA|BNEF|S&P\s*Global)/i
|
|
158
|
+
const TIER3_PUBLISHER_RE = /(?:百家号|知乎|小红书|抖音|头条|公众号|自媒体|博客|论坛|贴吧|CSDN|搜狐|网易号|新浪博客|行业博客|Industry\s*Blog|Medium|Reddit|Quora|匿名)/i
|
|
24
159
|
|
|
25
160
|
function cleanText(value, maxLen = 240) {
|
|
26
161
|
return String(value ?? '').replace(/\s+/g, ' ').trim().slice(0, maxLen)
|
|
@@ -34,19 +169,31 @@ function estimateTextWidth(text) {
|
|
|
34
169
|
return w
|
|
35
170
|
}
|
|
36
171
|
|
|
37
|
-
function trimCellByWidth(text, maxWidth =
|
|
172
|
+
function trimCellByWidth(text, maxWidth = 22.5) {
|
|
38
173
|
const s = cleanText(text, 160)
|
|
39
174
|
if (!s || estimateTextWidth(s) <= maxWidth) return s
|
|
40
175
|
let out = ''
|
|
41
176
|
let w = 0
|
|
42
177
|
const limit = Math.max(4, maxWidth - 1.1)
|
|
43
|
-
|
|
178
|
+
let cutIdx = s.length
|
|
179
|
+
for (let i = 0; i < s.length; i += 1) {
|
|
180
|
+
const ch = s[i]
|
|
44
181
|
const cw = /[^\x00-\xff]/.test(ch) ? 1 : 0.55
|
|
45
|
-
if (w + cw > limit)
|
|
182
|
+
if (w + cw > limit) {
|
|
183
|
+
cutIdx = i
|
|
184
|
+
break
|
|
185
|
+
}
|
|
46
186
|
out += ch
|
|
47
187
|
w += cw
|
|
48
188
|
}
|
|
49
|
-
|
|
189
|
+
// Avoid mid-ASCII-word chopping when cutting before an ASCII alphanumeric character
|
|
190
|
+
if (cutIdx < s.length && /[A-Za-z0-9]/.test(s[cutIdx]) && /[A-Za-z0-9._-]$/.test(out)) {
|
|
191
|
+
const backed = out.replace(/[A-Za-z0-9._-]+$/, '')
|
|
192
|
+
if (estimateTextWidth(backed) >= 5) {
|
|
193
|
+
out = backed
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
out = out.replace(/[\s,,、;;::(\[(【《「『&.-]+$/, '')
|
|
50
197
|
// Drop an unclosed opening title/paren fragment if cut mid-phrase (e.g. "GGII《2025" -> "GGII")
|
|
51
198
|
out = out.replace(/[《((「『【][^》))」』】]*$/, '').replace(/[\s,,、;;::&-]+$/, '')
|
|
52
199
|
return (out || s.slice(0, 6)) + '…'
|
|
@@ -67,12 +214,270 @@ function sanitizeHttpUrl(raw) {
|
|
|
67
214
|
}
|
|
68
215
|
}
|
|
69
216
|
|
|
217
|
+
function extractHost(url) {
|
|
218
|
+
if (!url) return ''
|
|
219
|
+
try {
|
|
220
|
+
return new URL(url).hostname.toLowerCase().replace(/^www\./, '')
|
|
221
|
+
} catch {
|
|
222
|
+
return ''
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function hostMatchesDomain(host, domain) {
|
|
227
|
+
if (!host || !domain) return false
|
|
228
|
+
const cleanDom = String(domain).toLowerCase().replace(/^www\./, '').trim()
|
|
229
|
+
if (!cleanDom) return false
|
|
230
|
+
return host === cleanDom || host.endsWith('.' + cleanDom)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function normalizeOriginToken(raw) {
|
|
234
|
+
const s = cleanText(raw, 32).toLowerCase()
|
|
235
|
+
if (!s) return ''
|
|
236
|
+
if (s === 'local-file' || s === 'local' || s === 'internal' || s === 'file') return 'local-file'
|
|
237
|
+
if (s === 'web-research' || s === 'web' || s === 'external' || s === 'research' || s === 'online') return 'web-research'
|
|
238
|
+
return ''
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function normalizeTierToken(raw) {
|
|
242
|
+
if (raw === undefined || raw === null || raw === '') return undefined
|
|
243
|
+
if (typeof raw === 'number' && Number.isInteger(raw) && raw >= 1 && raw <= 3) return raw
|
|
244
|
+
const m = /^t?([123])$/i.exec(String(raw).trim())
|
|
245
|
+
if (m) return Number(m[1])
|
|
246
|
+
throw new Error(`dsh-ppt:evidence.tier 仅支持 1 / 2 / 3(或 T1 / T2 / T3):${raw}`)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* 自动识别调研选题所属 8 大专业领域,用于路由权威信源白名单。
|
|
251
|
+
*/
|
|
252
|
+
export function detectResearchDomain(topic, context = '') {
|
|
253
|
+
const hay = `${topic || ''} ${context || ''}`.trim()
|
|
254
|
+
const order = ['medical-clinical', 'energy-climate', 'finance-filings', 'ai-tech', 'academic-science', 'consumer-retail', 'gov-macro']
|
|
255
|
+
for (const id of order) {
|
|
256
|
+
if (AUTHORITATIVE_DOMAINS[id].keywords.test(hay)) return AUTHORITATIVE_DOMAINS[id]
|
|
257
|
+
}
|
|
258
|
+
return AUTHORITATIVE_DOMAINS['general-business']
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* 代码级权威信源自动定级器:
|
|
263
|
+
* - 区分 `local-file`(本地资料)与 `web-research`(外部权威检索);
|
|
264
|
+
* - 按域名与机构名判定 Tier 1 / Tier 2 / Tier 3,并尊重工作区 `preferredSources` / `blockedDomains`;
|
|
265
|
+
* - 精准捕获「名义 T1/T2 机构 + 实际 T3 媒体转引链接」(`isSecondaryRelay: true`)。
|
|
266
|
+
*/
|
|
267
|
+
export function classifySourceAuthority(input = {}, options = {}) {
|
|
268
|
+
const source = cleanText(input.source, 160)
|
|
269
|
+
const url = typeof input.url === 'string' ? input.url.trim() : ''
|
|
270
|
+
const host = extractHost(url)
|
|
271
|
+
const preferred = (Array.isArray(options.preferredSources) ? options.preferredSources : [])
|
|
272
|
+
.map((s) => String(s).toLowerCase().trim())
|
|
273
|
+
.filter(Boolean)
|
|
274
|
+
const blocked = (Array.isArray(options.blockedDomains) ? options.blockedDomains : [])
|
|
275
|
+
.map((s) => String(s).toLowerCase().trim())
|
|
276
|
+
.filter(Boolean)
|
|
277
|
+
|
|
278
|
+
const explicitOrigin = normalizeOriginToken(input.origin)
|
|
279
|
+
let origin = explicitOrigin
|
|
280
|
+
if (!origin) {
|
|
281
|
+
if (url) origin = 'web-research'
|
|
282
|
+
else if (LOCAL_SOURCE_RE.test(source) || LOCAL_SOURCE_LABEL_RE.test(source)) origin = 'local-file'
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
let urlTier
|
|
286
|
+
let isBlockedDomain = false
|
|
287
|
+
let matchedDomain = ''
|
|
288
|
+
|
|
289
|
+
if (host) {
|
|
290
|
+
const hitBlocked = blocked.find((d) => hostMatchesDomain(host, d))
|
|
291
|
+
if (hitBlocked) {
|
|
292
|
+
urlTier = 3
|
|
293
|
+
isBlockedDomain = true
|
|
294
|
+
matchedDomain = hitBlocked
|
|
295
|
+
} else {
|
|
296
|
+
const hitPref = preferred.find((d) => d.includes('.') && hostMatchesDomain(host, d))
|
|
297
|
+
if (hitPref) {
|
|
298
|
+
urlTier = 1
|
|
299
|
+
matchedDomain = hitPref
|
|
300
|
+
} else {
|
|
301
|
+
const hitNoise = NOISE_DOMAINS.find((d) => hostMatchesDomain(host, d))
|
|
302
|
+
if (hitNoise) {
|
|
303
|
+
urlTier = 3
|
|
304
|
+
matchedDomain = hitNoise
|
|
305
|
+
} else {
|
|
306
|
+
const hitT1 = [...ALL_TIER1_DOMAINS].find((d) => hostMatchesDomain(host, d))
|
|
307
|
+
if (hitT1) {
|
|
308
|
+
urlTier = 1
|
|
309
|
+
matchedDomain = hitT1
|
|
310
|
+
} else {
|
|
311
|
+
const hitT2 = [...ALL_TIER2_DOMAINS].find((d) => hostMatchesDomain(host, d))
|
|
312
|
+
if (hitT2) {
|
|
313
|
+
urlTier = 2
|
|
314
|
+
matchedDomain = hitT2
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
let sourceTier
|
|
323
|
+
if (source) {
|
|
324
|
+
const hitPrefLabel = preferred.find((p) => !p.includes('.') && source.toLowerCase().includes(p))
|
|
325
|
+
if (hitPrefLabel) sourceTier = 1
|
|
326
|
+
else if (TIER1_PUBLISHER_RE.test(source)) sourceTier = 1
|
|
327
|
+
else if (TIER2_PUBLISHER_RE.test(source)) sourceTier = 2
|
|
328
|
+
else if (TIER3_PUBLISHER_RE.test(source)) sourceTier = 3
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const isSecondaryRelay = Boolean(
|
|
332
|
+
origin !== 'local-file' &&
|
|
333
|
+
urlTier === 3 &&
|
|
334
|
+
(sourceTier === 1 || sourceTier === 2),
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
let inferredTier
|
|
338
|
+
if (origin === 'local-file') {
|
|
339
|
+
inferredTier = 1
|
|
340
|
+
} else if (isBlockedDomain || urlTier === 3) {
|
|
341
|
+
inferredTier = 3
|
|
342
|
+
} else if (urlTier !== undefined) {
|
|
343
|
+
inferredTier = urlTier
|
|
344
|
+
} else if (sourceTier !== undefined) {
|
|
345
|
+
inferredTier = sourceTier
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const explicitTier = input.tier !== undefined ? normalizeTierToken(input.tier) : undefined
|
|
349
|
+
const effectiveTier = isBlockedDomain ? 3 : (explicitTier ?? inferredTier)
|
|
350
|
+
|
|
351
|
+
return {
|
|
352
|
+
origin: origin || undefined,
|
|
353
|
+
tier: effectiveTier,
|
|
354
|
+
urlTier,
|
|
355
|
+
sourceTier,
|
|
356
|
+
isSecondaryRelay,
|
|
357
|
+
isBlockedDomain,
|
|
358
|
+
matchedDomain: matchedDomain || host || undefined,
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* 为指定选题生成「8 大领域权威信源精准检索包」:
|
|
364
|
+
* 直接带 `site:` 权威白名单、`filetype:pdf` 官方报告指令,以及 `-site:` 营销号排除清单。
|
|
365
|
+
*/
|
|
366
|
+
export function buildAuthoritativeQueryPack(options = {}) {
|
|
367
|
+
const topic = cleanText(options.topic ?? options.title, 140)
|
|
368
|
+
const langEn = String(options.lang || 'zh').toLowerCase() === 'en'
|
|
369
|
+
const domain = options.domain && AUTHORITATIVE_DOMAINS[options.domain]
|
|
370
|
+
? AUTHORITATIVE_DOMAINS[options.domain]
|
|
371
|
+
: detectResearchDomain(topic, options.context || '')
|
|
372
|
+
|
|
373
|
+
const preferredDomains = (Array.isArray(options.preferredSources) ? options.preferredSources : [])
|
|
374
|
+
.map((s) => String(s).toLowerCase().trim())
|
|
375
|
+
.filter((s) => s.includes('.'))
|
|
376
|
+
const blockedDomains = (Array.isArray(options.blockedDomains) ? options.blockedDomains : [])
|
|
377
|
+
.map((s) => String(s).toLowerCase().trim())
|
|
378
|
+
.filter((s) => s.includes('.'))
|
|
379
|
+
|
|
380
|
+
const t1List = [...new Set([...preferredDomains, ...domain.tier1Domains])].slice(0, 6)
|
|
381
|
+
const t2List = [...new Set(domain.tier2Domains)].slice(0, 5)
|
|
382
|
+
const excludeList = [...new Set([
|
|
383
|
+
...blockedDomains,
|
|
384
|
+
...(langEn
|
|
385
|
+
? ['medium.com', 'reddit.com', 'quora.com']
|
|
386
|
+
: ['baijiahao.baidu.com', 'sohu.com', 'zhihu.com', '163.com']),
|
|
387
|
+
])].slice(0, 5)
|
|
388
|
+
|
|
389
|
+
const t1SiteClause = t1List.slice(0, 4).map((d) => `site:${d}`).join(' OR ')
|
|
390
|
+
const t2SiteClause = t2List.slice(0, 4).map((d) => `site:${d}`).join(' OR ')
|
|
391
|
+
const excludeClause = excludeList.map((d) => `-site:${d}`).join(' ')
|
|
392
|
+
const yr = new Date().getFullYear()
|
|
393
|
+
const yrs = `${yr - 1} ${yr}`
|
|
394
|
+
|
|
395
|
+
const rounds = langEn
|
|
396
|
+
? [
|
|
397
|
+
{
|
|
398
|
+
round: 1,
|
|
399
|
+
tierTarget: 'Tier 1 (Official / Regulatory / Listed Filings)',
|
|
400
|
+
goal: 'Primary Official & Authoritative Baseline',
|
|
401
|
+
queries: [
|
|
402
|
+
`"${topic}" (${t1SiteClause}) ${yrs}`,
|
|
403
|
+
`"${topic}" filetype:pdf (report OR whitepaper OR statistics) ${yrs} ${excludeClause}`,
|
|
404
|
+
],
|
|
405
|
+
requirement: `Anchor headline market size, policy milestones, exact year & geographic scope in Tier 1 sources (${domain.tier1LabelsEn}).`,
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
round: 2,
|
|
409
|
+
tierTarget: 'Tier 1–2 (Analyst Benchmarks & Peer Filings)',
|
|
410
|
+
goal: 'Competitive Landscape & Quantitative Benchmarks',
|
|
411
|
+
queries: [
|
|
412
|
+
`"${topic}" (${t2SiteClause}) benchmark OR "market share" ${yrs}`,
|
|
413
|
+
`"${topic}" "annual report" OR "10-K" OR case study efficiency cost ${yrs} ${excludeClause}`,
|
|
414
|
+
],
|
|
415
|
+
requirement: 'Verify peer metrics under identical units & geographic scope; never rely on a media relay URL without tracing the original report.',
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
round: 3,
|
|
419
|
+
tierTarget: 'Tier 1–2 (Independent Risks & Forecast Range)',
|
|
420
|
+
goal: 'Latest Milestones, Bottlenecks & Counter-Evidence',
|
|
421
|
+
queries: [
|
|
422
|
+
`"${topic}" bottleneck OR risk OR limitation OR forecast ${yr} ${yr + 1} ${excludeClause}`,
|
|
423
|
+
`"${topic}" (${t1SiteClause}) roadmap OR compliance OR outlook ${yr}`,
|
|
424
|
+
],
|
|
425
|
+
requirement: 'Tag forward projections with claimType:"forecast" and record conflicting estimates as ranges; downgrade unsourced dimensions to qualitative diagrams.',
|
|
426
|
+
},
|
|
427
|
+
]
|
|
428
|
+
: [
|
|
429
|
+
{
|
|
430
|
+
round: 1,
|
|
431
|
+
tierTarget: 'Tier 1(官方部委 / 统计公报 / 上市财报 / 顶刊)',
|
|
432
|
+
goal: '一手官方与权威基线数据(市场/政策/年报)',
|
|
433
|
+
queries: [
|
|
434
|
+
`${topic} (${t1SiteClause}) ${yrs}`,
|
|
435
|
+
`${topic} filetype:pdf (白皮书 OR 年报 OR 统计公报) ${yrs} ${excludeClause}`,
|
|
436
|
+
],
|
|
437
|
+
requirement: `核心规模、增速与关键口径须直击 Tier 1 一手源(${domain.tier1LabelsZh}),记清年份与地域口径,拒收百家号/搜狐等二手软文。`,
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
round: 2,
|
|
441
|
+
tierTarget: 'Tier 1–2(权威研报机构 / 同业上市财报)',
|
|
442
|
+
goal: '行业标杆对比与量化实绩(竞品/成本/提效)',
|
|
443
|
+
queries: [
|
|
444
|
+
`${topic} (${t2SiteClause}) 市场份额 OR 对比 OR 基准 ${yrs}`,
|
|
445
|
+
`${topic} 上市公司年报 OR 招股书 成本 提效 实测 ${yrs} ${excludeClause}`,
|
|
446
|
+
],
|
|
447
|
+
requirement: '收集同单位、同地域口径竞品基准;若发现媒体转引某机构报告,须继续顺藤摸瓜核对原官网链接或标明转引。',
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
round: 3,
|
|
451
|
+
tierTarget: 'Tier 1–2(最新进展 / 政策风险 / 预测区间)',
|
|
452
|
+
goal: '最新进展、落地瓶颈与反方风险(避免一边倒)',
|
|
453
|
+
queries: [
|
|
454
|
+
`${topic} 痛点 OR 瓶颈 OR 风险 OR 预测 ${yr} ${yr + 1} ${excludeClause}`,
|
|
455
|
+
`${topic} (${t1SiteClause}) 路线图 OR 政策 OR 标准 ${yr}`,
|
|
456
|
+
],
|
|
457
|
+
requirement: '预测性数字须标记 claimType:"forecast" 并在画面注明“预计/E”;多机构口径分歧须如实展示区间;无确凿数字一律改定性图示。',
|
|
458
|
+
},
|
|
459
|
+
]
|
|
460
|
+
|
|
461
|
+
return {
|
|
462
|
+
domain: {
|
|
463
|
+
id: domain.id,
|
|
464
|
+
name: langEn ? domain.nameEn : domain.nameZh,
|
|
465
|
+
tier1Domains: t1List,
|
|
466
|
+
tier2Domains: t2List,
|
|
467
|
+
excludedDomains: excludeList,
|
|
468
|
+
tier1Summary: langEn ? domain.tier1LabelsEn : domain.tier1LabelsZh,
|
|
469
|
+
},
|
|
470
|
+
rounds,
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
70
474
|
/**
|
|
71
|
-
* 校验并规范化外部传入的 `evidence[]`
|
|
475
|
+
* 校验并规范化外部传入的 `evidence[]` 证据账本(支持 Mode B 零资料与 Mode C 混合资料)。
|
|
72
476
|
* @param {Array<object>} rawEvidence
|
|
477
|
+
* @param {object} [options]
|
|
73
478
|
* @returns {Array<object>}
|
|
74
479
|
*/
|
|
75
|
-
export function normalizeEvidenceLedger(rawEvidence) {
|
|
480
|
+
export function normalizeEvidenceLedger(rawEvidence, options = {}) {
|
|
76
481
|
if (rawEvidence === undefined || rawEvidence === null) return []
|
|
77
482
|
if (!Array.isArray(rawEvidence)) {
|
|
78
483
|
throw new Error('dsh-ppt:evidence 必须是证据条目数组')
|
|
@@ -96,8 +501,15 @@ export function normalizeEvidenceLedger(rawEvidence) {
|
|
|
96
501
|
}
|
|
97
502
|
seen.add(rawId)
|
|
98
503
|
|
|
504
|
+
const rawOriginToken = normalizeOriginToken(item.origin)
|
|
505
|
+
if (item.origin !== undefined && item.origin !== null && item.origin !== '' && !rawOriginToken && (item.source || item.publisher)) {
|
|
506
|
+
throw new Error(`dsh-ppt:evidence ${rawId} 的 origin 仅支持 local-file / web-research`)
|
|
507
|
+
}
|
|
508
|
+
|
|
99
509
|
const claim = cleanText(item.claim ?? item.fact ?? item.summary, 320)
|
|
100
|
-
|
|
510
|
+
// Backwards compatibility: only fall back to item.origin as publisher name if it is NOT a reserved origin keyword
|
|
511
|
+
const fallbackOriginSource = rawOriginToken ? '' : item.origin
|
|
512
|
+
const source = cleanText(item.source ?? item.publisher ?? fallbackOriginSource, 160)
|
|
101
513
|
if (!claim) {
|
|
102
514
|
throw new Error(`dsh-ppt:evidence ${rawId} 缺少事实描述 claim`)
|
|
103
515
|
}
|
|
@@ -111,7 +523,23 @@ export function normalizeEvidenceLedger(rawEvidence) {
|
|
|
111
523
|
if (!CONFIDENCE_SET.has(rawConf)) {
|
|
112
524
|
throw new Error(`dsh-ppt:evidence ${rawId} 的 confidence 仅支持 verified / estimated / conflicting / unverified`)
|
|
113
525
|
}
|
|
526
|
+
const explicitTier = normalizeTierToken(item.tier)
|
|
527
|
+
const rawClaimType = cleanText(item.claimType ?? item.kind, 24).toLowerCase()
|
|
528
|
+
if (rawClaimType && !CLAIM_TYPE_SET.has(rawClaimType)) {
|
|
529
|
+
throw new Error(`dsh-ppt:evidence ${rawId} 的 claimType 仅支持 actual / forecast / policy / benchmark`)
|
|
530
|
+
}
|
|
114
531
|
const note = cleanText(item.note ?? item.caveat, 240)
|
|
532
|
+
|
|
533
|
+
const auth = classifySourceAuthority({
|
|
534
|
+
source,
|
|
535
|
+
url,
|
|
536
|
+
origin: rawOriginToken || undefined,
|
|
537
|
+
tier: explicitTier,
|
|
538
|
+
}, options)
|
|
539
|
+
|
|
540
|
+
const finalOrigin = rawOriginToken || auth.origin
|
|
541
|
+
const finalTier = explicitTier ?? (auth.tier !== undefined && (finalOrigin === 'web-research' || auth.isBlockedDomain) ? auth.tier : undefined)
|
|
542
|
+
|
|
115
543
|
out.push({
|
|
116
544
|
id: rawId,
|
|
117
545
|
claim,
|
|
@@ -120,12 +548,56 @@ export function normalizeEvidenceLedger(rawEvidence) {
|
|
|
120
548
|
...(scope ? { scope } : {}),
|
|
121
549
|
...(url ? { url } : {}),
|
|
122
550
|
confidence: rawConf,
|
|
551
|
+
...(finalOrigin ? { origin: finalOrigin } : {}),
|
|
552
|
+
...(finalTier !== undefined ? { tier: finalTier } : {}),
|
|
553
|
+
...(rawClaimType ? { claimType: rawClaimType } : {}),
|
|
123
554
|
...(note ? { note } : {}),
|
|
124
555
|
})
|
|
125
556
|
}
|
|
126
557
|
return out
|
|
127
558
|
}
|
|
128
559
|
|
|
560
|
+
/**
|
|
561
|
+
* 合并本地资料证据与外部权威检索证据,自动顺延外部证据编号(避免 ID 冲突),并返回映射表。
|
|
562
|
+
*/
|
|
563
|
+
export function mergeHybridEvidence(localEvidence = [], externalEvidence = [], options = {}) {
|
|
564
|
+
const localNorm = normalizeEvidenceLedger(localEvidence.map((e) => ({ ...e, origin: e.origin || 'local-file' })), options)
|
|
565
|
+
const usedIds = new Set(localNorm.map((e) => e.id))
|
|
566
|
+
let maxNum = 0
|
|
567
|
+
for (const id of usedIds) {
|
|
568
|
+
const m = /^E(\d+)$/.exec(id)
|
|
569
|
+
if (m) maxNum = Math.max(maxNum, Number(m[1]))
|
|
570
|
+
}
|
|
571
|
+
const remappedIds = {}
|
|
572
|
+
const extRaw = Array.isArray(externalEvidence) ? externalEvidence : []
|
|
573
|
+
const extPrepared = extRaw.map((item) => {
|
|
574
|
+
const origId = cleanText(item?.id || '', 24).toUpperCase()
|
|
575
|
+
let nextId = origId
|
|
576
|
+
if (!nextId || usedIds.has(nextId)) {
|
|
577
|
+
maxNum += 1
|
|
578
|
+
nextId = `E${maxNum}`
|
|
579
|
+
} else {
|
|
580
|
+
const m = /^E(\d+)$/.exec(nextId)
|
|
581
|
+
if (m) maxNum = Math.max(maxNum, Number(m[1]))
|
|
582
|
+
}
|
|
583
|
+
usedIds.add(nextId)
|
|
584
|
+
if (origId && origId !== nextId) remappedIds[origId] = nextId
|
|
585
|
+
return {
|
|
586
|
+
...item,
|
|
587
|
+
id: nextId,
|
|
588
|
+
origin: item?.origin || 'web-research',
|
|
589
|
+
}
|
|
590
|
+
})
|
|
591
|
+
const extNorm = normalizeEvidenceLedger(extPrepared, options)
|
|
592
|
+
return {
|
|
593
|
+
evidence: [...localNorm, ...extNorm],
|
|
594
|
+
localCount: localNorm.length,
|
|
595
|
+
externalCount: extNorm.length,
|
|
596
|
+
remappedIds,
|
|
597
|
+
nextEvidenceId: `E${maxNum + 1}`,
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
129
601
|
/**
|
|
130
602
|
* 提取单页显式 `evidenceIds` 与正文内联 `[E1]` 引用编号(去重保序)。
|
|
131
603
|
*/
|
|
@@ -170,11 +642,27 @@ export function extractSlideEvidenceRefs(slide) {
|
|
|
170
642
|
return refs
|
|
171
643
|
}
|
|
172
644
|
|
|
645
|
+
function originShortTag(e, langEn) {
|
|
646
|
+
if (e.origin === 'local-file') return langEn ? 'Internal' : '内部'
|
|
647
|
+
if (e.origin === 'web-research') {
|
|
648
|
+
const t = e.tier ? `T${e.tier}` : ''
|
|
649
|
+
return langEn ? `Ext${t ? '·' + t : ''}` : `外源${t}`
|
|
650
|
+
}
|
|
651
|
+
return ''
|
|
652
|
+
}
|
|
653
|
+
|
|
173
654
|
function formatCompactEvidenceSource(entries, langEn) {
|
|
655
|
+
const hasMixedOrigins = entries.some((e) => e.origin === 'local-file') && entries.some((e) => e.origin === 'web-research')
|
|
174
656
|
const parts = entries.slice(0, 2).map((e) => {
|
|
175
|
-
const shortSrc = trimCellByWidth(e.source,
|
|
176
|
-
const
|
|
177
|
-
|
|
657
|
+
const shortSrc = trimCellByWidth(e.source, 15)
|
|
658
|
+
const metaBits = []
|
|
659
|
+
if (e.date) metaBits.push(e.date)
|
|
660
|
+
if (hasMixedOrigins || e.tier) {
|
|
661
|
+
const tag = originShortTag(e, langEn)
|
|
662
|
+
if (tag) metaBits.push(tag)
|
|
663
|
+
}
|
|
664
|
+
const metaStr = metaBits.length ? ` (${metaBits.join('·')})` : ''
|
|
665
|
+
return `${shortSrc}${metaStr} [${e.id}]`
|
|
178
666
|
})
|
|
179
667
|
const suffix = entries.length > 2 ? (langEn ? ` +${entries.length - 2} more` : ` 等 ${entries.length} 项`) : ''
|
|
180
668
|
return parts.join(langEn ? '; ' : ';') + suffix
|
|
@@ -196,7 +684,9 @@ function confidenceLabel(conf, langEn) {
|
|
|
196
684
|
function formatNotesProvenanceBlock(entries, langEn) {
|
|
197
685
|
const header = langEn ? '[Evidence Provenance]' : '[证据溯源]'
|
|
198
686
|
const lines = entries.map((e) => {
|
|
199
|
-
const
|
|
687
|
+
const originTag = originShortTag(e, langEn)
|
|
688
|
+
const claimKind = e.claimType === 'forecast' ? (langEn ? 'Forecast' : '预测口径') : (e.claimType === 'policy' ? (langEn ? 'Policy' : '政策口径') : '')
|
|
689
|
+
const meta = [originTag, e.source, e.date, e.scope, claimKind, confidenceLabel(e.confidence, langEn)].filter(Boolean).join(' · ')
|
|
200
690
|
const urlPart = e.url ? ` | ${e.url}` : ''
|
|
201
691
|
const notePart = e.note ? ` (${e.note})` : ''
|
|
202
692
|
return `- [${e.id}] ${e.claim} — ${meta}${notePart}${urlPart}`
|
|
@@ -207,8 +697,8 @@ function formatNotesProvenanceBlock(entries, langEn) {
|
|
|
207
697
|
/**
|
|
208
698
|
* 将核验后的证据账本绑定至幻灯片:
|
|
209
699
|
* - 自动为引用 `[E#]` / `evidenceIds` 的页面注入干净的 `slide.source` 脚注;
|
|
210
|
-
* -
|
|
211
|
-
* - 若 `evidenceAppendix: true
|
|
700
|
+
* - 将完整出处、统计口径、内部/外源 Tier 级别、核验状态与原始 URL 写入演讲备注 `notes`;
|
|
701
|
+
* - 若 `evidenceAppendix: true`,在封底前自动插入「数据来源与事实核验清单」三线表附录页(混源时自动区隔内部资料与权威外源)。
|
|
212
702
|
*/
|
|
213
703
|
export function applyEvidenceLedgerToSlides(slides, ledger, options = {}) {
|
|
214
704
|
const list = Array.isArray(slides) ? slides : []
|
|
@@ -256,44 +746,60 @@ export function applyEvidenceLedgerToSlides(slides, ledger, options = {}) {
|
|
|
256
746
|
: items
|
|
257
747
|
const appendixEntries = [...rawAppendixEntries].sort(compareEvidenceId)
|
|
258
748
|
const maxRows = 6
|
|
259
|
-
const
|
|
260
|
-
|
|
749
|
+
const localCount = appendixEntries.filter((e) => e.origin === 'local-file').length
|
|
750
|
+
const externalCount = appendixEntries.filter((e) => e.origin === 'web-research').length
|
|
751
|
+
const isHybrid = localCount > 0 && externalCount > 0
|
|
752
|
+
|
|
753
|
+
const shortStatus = (e) => {
|
|
754
|
+
if (isHybrid) {
|
|
755
|
+
if (e.origin === 'local-file') return langEn ? 'Internal' : '内部资料'
|
|
756
|
+
const t = e.tier ? `T${e.tier}` : 'OK'
|
|
757
|
+
return langEn ? `Ext·${t}` : `外源·${t}`
|
|
758
|
+
}
|
|
759
|
+
if (langEn) return confidenceLabel(e.confidence, true)
|
|
261
760
|
const compactZh = { verified: '已核验', estimated: '口径估算', conflicting: '口径差异', unverified: '待核实' }
|
|
262
|
-
return compactZh[
|
|
761
|
+
return compactZh[e.confidence] || e.confidence
|
|
263
762
|
}
|
|
763
|
+
|
|
264
764
|
const rows = [
|
|
265
765
|
langEn
|
|
266
|
-
? ['ID', 'Key Verified Fact', 'Primary Source & Year', 'Status']
|
|
267
|
-
: ['编号', '核心核验事实', '一手出处与年份', '核验状态'],
|
|
766
|
+
? ['ID', 'Key Verified Fact', 'Primary Source & Year', isHybrid ? 'Origin' : 'Status']
|
|
767
|
+
: ['编号', '核心核验事实', '一手出处与年份', isHybrid ? '来源类别' : '核验状态'],
|
|
268
768
|
...appendixEntries.slice(0, maxRows).map((e) => {
|
|
269
769
|
const datePart = e.date ? ` (${e.date})` : ''
|
|
270
|
-
const srcBudget = Math.max(
|
|
770
|
+
const srcBudget = Math.max(10, 22.5 - estimateTextWidth(datePart))
|
|
271
771
|
const srcWithDate = `${trimCellByWidth(e.source, srcBudget)}${datePart}`
|
|
272
772
|
return [
|
|
273
773
|
trimCellByWidth(e.id, 6),
|
|
274
|
-
trimCellByWidth(e.claim,
|
|
774
|
+
trimCellByWidth(e.claim, 21.5),
|
|
275
775
|
srcWithDate,
|
|
276
|
-
trimCellByWidth(shortStatus(e
|
|
776
|
+
trimCellByWidth(shortStatus(e), 6.4),
|
|
277
777
|
]
|
|
278
778
|
}),
|
|
279
779
|
]
|
|
280
780
|
const verifiedCount = appendixEntries.filter((e) => e.confidence === 'verified').length
|
|
281
781
|
const allVerified = verifiedCount === appendixEntries.length
|
|
282
782
|
const shownCount = Math.min(maxRows, appendixEntries.length)
|
|
783
|
+
const appendixTitle = isHybrid
|
|
784
|
+
? (langEn
|
|
785
|
+
? `Hybrid Evidence Ledger: ${localCount} Internal + ${externalCount} External Sources`
|
|
786
|
+
: `全篇双轨溯源清单:内部资料 ${localCount} 项 × 权威外源 ${externalCount} 项`)
|
|
787
|
+
: (langEn
|
|
788
|
+
? (allVerified
|
|
789
|
+
? `All ${appendixEntries.length} Core Claims Verified Against Primary Sources`
|
|
790
|
+
: `Evidence Ledger: ${verifiedCount}/${appendixEntries.length} Core Claims Verified`)
|
|
791
|
+
: (allVerified
|
|
792
|
+
? `全篇 ${appendixEntries.length} 项核心论据均已完成一手出处核验`
|
|
793
|
+
: `全篇 ${appendixEntries.length} 项核心论据溯源清单(已核验 ${verifiedCount} 项)`))
|
|
794
|
+
|
|
283
795
|
const appendixSlide = {
|
|
284
796
|
layout: 'table',
|
|
285
797
|
tableStyle: 'booktabs',
|
|
286
798
|
kicker: langEn ? 'APPENDIX · SOURCES' : '附录 · 事实溯源',
|
|
287
|
-
title:
|
|
288
|
-
? (allVerified
|
|
289
|
-
? `All ${appendixEntries.length} Core Claims Verified Against Primary Sources`
|
|
290
|
-
: `Evidence Ledger: ${verifiedCount}/${appendixEntries.length} Core Claims Verified`)
|
|
291
|
-
: (allVerified
|
|
292
|
-
? `全篇 ${appendixEntries.length} 项核心论据均已完成一手出处核验`
|
|
293
|
-
: `全篇 ${appendixEntries.length} 项核心论据溯源清单(已核验 ${verifiedCount} 项)`),
|
|
799
|
+
title: appendixTitle,
|
|
294
800
|
rows,
|
|
295
801
|
takeaway: langEn
|
|
296
|
-
? `${shownCount < appendixEntries.length ? `Showing ${shownCount} of ${appendixEntries.length}` : `All ${appendixEntries.length}`} ledger entries carry
|
|
802
|
+
? `${shownCount < appendixEntries.length ? `Showing ${shownCount} of ${appendixEntries.length}` : `All ${appendixEntries.length}`} ledger entries carry provenance metadata; full claims and URLs are preserved in speaker notes and handout.`
|
|
297
803
|
: `${shownCount < appendixEntries.length ? `表内列出 ${shownCount}/${appendixEntries.length} 条` : `共列出全部 ${appendixEntries.length} 条`}核心证据,完整原文链接、口径说明与备注已同步保存在演讲备注与讲义中。`,
|
|
298
804
|
notes: formatNotesProvenanceBlock(appendixEntries, langEn),
|
|
299
805
|
}
|
|
@@ -321,12 +827,27 @@ function slideHasNumericClaims(slide) {
|
|
|
321
827
|
return /\d+(?:\.\d+)?\s*(?:%|%|亿|万|M|B|GWh|GW|TB|ms|倍|x|元|美元|\$|¥)/i.test(text)
|
|
322
828
|
}
|
|
323
829
|
|
|
830
|
+
function visibleSlideContext(slide) {
|
|
831
|
+
const rawNotes = String(slide?.notes || '')
|
|
832
|
+
const authorNotes = rawNotes.split(/\[(?:证据溯源|Evidence Provenance)\]/)[0] || ''
|
|
833
|
+
const itemText = Array.isArray(slide?.items)
|
|
834
|
+
? slide.items.flatMap((it) => [it?.tag, it?.title, it?.value, it?.delta, it?.text]).filter(Boolean).join(' ')
|
|
835
|
+
: ''
|
|
836
|
+
const bulletText = Array.isArray(slide?.bullets) ? slide.bullets.join(' ') : ''
|
|
837
|
+
return `${slide?.title || ''} ${slide?.subtitle || ''} ${slide?.takeaway || ''} ${slide?.source || ''} ${itemText} ${bulletText} ${authorNotes}`
|
|
838
|
+
}
|
|
839
|
+
|
|
324
840
|
/**
|
|
325
|
-
* SLOP-13
|
|
841
|
+
* SLOP-13 事实出处与权威信源静态门禁(100% 确定性、零误报)。
|
|
326
842
|
* 1. 拦截悬空 `[E99]` 引用;
|
|
327
843
|
* 2. 拦截将 `unverified` / `conflicting` 证据当作无说明定论展示;
|
|
328
844
|
* 3. 拦截「数据来源:网络整理 / 公开资料」等空洞占位假出处;
|
|
329
|
-
* 4.
|
|
845
|
+
* 4. 调研模式下拦截无出处且未绑定 `[E#]` 的量化数据页;
|
|
846
|
+
* 5. v0.35 权威信源深度审计:
|
|
847
|
+
* - `low-authority-source`:把 T3 噪声/营销号/黑名单站点标成 `verified` 且未加口径说明;
|
|
848
|
+
* - `secondary-relay-source`:名义 T1/T2 权威机构但实际 URL 为自媒体/资讯站二手转引;
|
|
849
|
+
* - `unmarked-forecast-claim`:`claimType: 'forecast'` 预测数据上屏却未标注“预计/预测/E/Forecast”;
|
|
850
|
+
* - `missing-external-date` / `stale-evidence-date`:外部权威数据缺失年份或基准过旧(≥4年前且非历史回顾)。
|
|
330
851
|
*/
|
|
331
852
|
export function auditEvidenceAndSourcing(manifest) {
|
|
332
853
|
const issues = []
|
|
@@ -336,6 +857,12 @@ export function auditEvidenceAndSourcing(manifest) {
|
|
|
336
857
|
const ledger = Array.isArray(manifest?.evidence) ? manifest.evidence : []
|
|
337
858
|
const hasLedger = ledger.length > 0
|
|
338
859
|
const byId = new Map(ledger.map((e) => [String(e?.id ?? '').toUpperCase(), e]))
|
|
860
|
+
const brandKit = manifest?.brandKit || {}
|
|
861
|
+
const authOpts = {
|
|
862
|
+
preferredSources: brandKit.preferredSources,
|
|
863
|
+
blockedDomains: brandKit.blockedDomains,
|
|
864
|
+
}
|
|
865
|
+
const currentYear = new Date().getFullYear()
|
|
339
866
|
|
|
340
867
|
const push = (index, code, message, suggestion) => {
|
|
341
868
|
issues.push({
|
|
@@ -354,7 +881,7 @@ export function auditEvidenceAndSourcing(manifest) {
|
|
|
354
881
|
const isFraming = ['cover', 'section', 'closing', 'agenda', 'quote'].includes(lay)
|
|
355
882
|
const rawSource = String(slide.source ?? '').trim()
|
|
356
883
|
|
|
357
|
-
// 1.
|
|
884
|
+
// 1. 拦截空洞假出处
|
|
358
885
|
if (rawSource && VAGUE_SOURCE_RE.test(rawSource)) {
|
|
359
886
|
push(
|
|
360
887
|
i,
|
|
@@ -364,7 +891,7 @@ export function auditEvidenceAndSourcing(manifest) {
|
|
|
364
891
|
)
|
|
365
892
|
}
|
|
366
893
|
|
|
367
|
-
// 2. 检查 `[E#]` / `evidenceIds`
|
|
894
|
+
// 2. 检查 `[E#]` / `evidenceIds` 悬空引用、未核验/冲突状态、T3 权威度与二手转引
|
|
368
895
|
const refs = extractSlideEvidenceRefs(slide)
|
|
369
896
|
if (refs.length > 0) {
|
|
370
897
|
const missing = refs.filter((id) => !byId.has(id))
|
|
@@ -376,15 +903,12 @@ export function auditEvidenceAndSourcing(manifest) {
|
|
|
376
903
|
'请在 evidence[] 中补齐对应核验条目与原始出处,或移除悬空引用编号',
|
|
377
904
|
)
|
|
378
905
|
}
|
|
379
|
-
|
|
906
|
+
|
|
907
|
+
const matchedEntries = refs.map((id) => byId.get(id)).filter(Boolean)
|
|
908
|
+
const caveatContext = visibleSlideContext(slide)
|
|
909
|
+
|
|
910
|
+
const risky = matchedEntries.filter((e) => e.confidence === 'unverified' || e.confidence === 'conflicting')
|
|
380
911
|
if (risky.length > 0) {
|
|
381
|
-
const rawNotes = String(slide.notes || '')
|
|
382
|
-
const authorNotes = rawNotes.split(/\[(?:证据溯源|Evidence Provenance)\]/)[0] || ''
|
|
383
|
-
const itemText = Array.isArray(slide.items)
|
|
384
|
-
? slide.items.flatMap((it) => [it?.tag, it?.title, it?.delta, it?.text]).filter(Boolean).join(' ')
|
|
385
|
-
: ''
|
|
386
|
-
const bulletText = Array.isArray(slide.bullets) ? slide.bullets.join(' ') : ''
|
|
387
|
-
const caveatContext = `${slide.title || ''} ${slide.subtitle || ''} ${slide.takeaway || ''} ${slide.source || ''} ${itemText} ${bulletText} ${authorNotes}`
|
|
388
912
|
const hasCaveat = /待核实|未核实|冲突|差异|区间|口径|估算|约\s*\d|caveat|conflict|unverified|range|estimate|approx/i.test(caveatContext)
|
|
389
913
|
if (!hasCaveat) {
|
|
390
914
|
push(
|
|
@@ -395,6 +919,83 @@ export function auditEvidenceAndSourcing(manifest) {
|
|
|
395
919
|
)
|
|
396
920
|
}
|
|
397
921
|
}
|
|
922
|
+
|
|
923
|
+
// 2B. 代码级权威信源分级 & 二手转引审计
|
|
924
|
+
const relayEntries = []
|
|
925
|
+
const lowAuthEntries = []
|
|
926
|
+
const unmarkedForecasts = []
|
|
927
|
+
const missingDateEntries = []
|
|
928
|
+
const staleEntries = []
|
|
929
|
+
|
|
930
|
+
for (const e of matchedEntries) {
|
|
931
|
+
const auth = classifySourceAuthority(e, authOpts)
|
|
932
|
+
if (auth.isSecondaryRelay) {
|
|
933
|
+
const relayAcknowledged = /转引|转述|媒体|via\b|cited\s+by|secondary|relay/i.test(`${e.source} ${e.note || ''} ${caveatContext}`)
|
|
934
|
+
if (!relayAcknowledged) relayEntries.push(`${e.id}(${auth.matchedDomain || 'T3'})`)
|
|
935
|
+
} else if ((auth.tier === 3 || auth.isBlockedDomain) && e.confidence === 'verified') {
|
|
936
|
+
const hasCaveat = /估算|参考|媒体|二手|转引|待核实|仅供参考|estimate|media|secondary|blog|approx/i.test(`${e.note || ''} ${caveatContext}`)
|
|
937
|
+
if (!hasCaveat || auth.isBlockedDomain) {
|
|
938
|
+
lowAuthEntries.push(`${e.id}(${auth.matchedDomain || 'Tier 3'})`)
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
if (e.claimType === 'forecast') {
|
|
943
|
+
const hasForecastLabel = /预计|预测|展望|估算|预期|\b20\d{2}\s*E\b|forecast|projected|projection|outlook|est\.|estimated/i.test(caveatContext)
|
|
944
|
+
if (!hasForecastLabel) unmarkedForecasts.push(e.id)
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
if (auth.origin === 'web-research' && e.confidence === 'verified' && !e.date) {
|
|
948
|
+
missingDateEntries.push(e.id)
|
|
949
|
+
} else if (auth.origin === 'web-research' && e.date && (e.claimType === 'benchmark' || QUANT_LAYOUTS.has(lay))) {
|
|
950
|
+
const ym = /\b(19\d{2}|20\d{2})\b/.exec(e.date)
|
|
951
|
+
const year = ym ? Number(ym[1]) : NaN
|
|
952
|
+
if (Number.isFinite(year) && year <= currentYear - 4) {
|
|
953
|
+
const isHistorical = /历史|演变|历程|基线|回溯|十年|history|historical|evolution|since\s+\d{4}|baseline/i.test(`${caveatContext} ${e.note || ''}`)
|
|
954
|
+
if (!isHistorical) staleEntries.push(`${e.id}(${year})`)
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
if (relayEntries.length > 0) {
|
|
960
|
+
push(
|
|
961
|
+
i,
|
|
962
|
+
'secondary-relay-source',
|
|
963
|
+
`证据 ${relayEntries.join('、')} 声称权威机构但链接指向自媒体/资讯站二手转引(SLOP-13)`,
|
|
964
|
+
'请顺藤摸瓜核对原始机构官网/PDF 报告链接,或在 source/note 中明确注明「媒体转引」',
|
|
965
|
+
)
|
|
966
|
+
}
|
|
967
|
+
if (lowAuthEntries.length > 0) {
|
|
968
|
+
push(
|
|
969
|
+
i,
|
|
970
|
+
'low-authority-source',
|
|
971
|
+
`证据 ${lowAuthEntries.join('、')} 属于 Tier 3 自媒体/论坛/屏蔽站点,却以已核验定论呈现(SLOP-13)`,
|
|
972
|
+
'请替换为 Tier 1/2 政府公报、上市财报、顶刊或权威研报,或改为 estimated 并在画面说明口径',
|
|
973
|
+
)
|
|
974
|
+
}
|
|
975
|
+
if (unmarkedForecasts.length > 0) {
|
|
976
|
+
push(
|
|
977
|
+
i,
|
|
978
|
+
'unmarked-forecast-claim',
|
|
979
|
+
`证据 ${unmarkedForecasts.join('、')} 属于预测口径(forecast),但画面文案未标注「预计 / 预测 / E」(SLOP-13)`,
|
|
980
|
+
'请在标题、指标或 takeaway 中明确区分预测值与历史实绩(如标注「2028E 预计」)',
|
|
981
|
+
)
|
|
982
|
+
}
|
|
983
|
+
if (missingDateEntries.length > 0) {
|
|
984
|
+
push(
|
|
985
|
+
i,
|
|
986
|
+
'missing-external-date',
|
|
987
|
+
`外部权威证据 ${missingDateEntries.join('、')} 缺少发布年份/统计周期 date(SLOP-13)`,
|
|
988
|
+
'请在 evidence[].date 中补齐准确年份或季度(如 "2026-Q1" / "2025")以确保时效可追溯',
|
|
989
|
+
)
|
|
990
|
+
}
|
|
991
|
+
if (staleEntries.length > 0) {
|
|
992
|
+
push(
|
|
993
|
+
i,
|
|
994
|
+
'stale-evidence-date',
|
|
995
|
+
`外部基准证据 ${staleEntries.join('、')} 距今已超过 3 年,可能存在数据时效过期(SLOP-13)`,
|
|
996
|
+
`请优先检索 ${currentYear - 1}–${currentYear} 最新年度数据,或在页面中注明为历史基线对比`,
|
|
997
|
+
)
|
|
998
|
+
}
|
|
398
999
|
}
|
|
399
1000
|
|
|
400
1001
|
// 3. 调研模式(存在 evidence[] 账本时)要求所有高密度量化数据页给出真实出处或绑定 [E#]
|
|
@@ -422,29 +1023,166 @@ export function renderEvidenceHandoutSection(manifest, language) {
|
|
|
422
1023
|
const ledger = Array.isArray(manifest?.evidence) ? manifest.evidence : []
|
|
423
1024
|
if (ledger.length === 0) return ''
|
|
424
1025
|
const en = (language || manifest?.language || 'zh') === 'en'
|
|
1026
|
+
const hasOriginOrTier = ledger.some((e) => e.origin || e.tier)
|
|
425
1027
|
const lines = [
|
|
426
1028
|
'',
|
|
427
1029
|
`## ${en ? 'Verified Evidence Ledger & Fact-Check Sources' : '事实核验与证据账本(Evidence Ledger)'}`,
|
|
428
1030
|
'',
|
|
429
|
-
|
|
430
|
-
?
|
|
431
|
-
|
|
432
|
-
|
|
1031
|
+
hasOriginOrTier
|
|
1032
|
+
? (en
|
|
1033
|
+
? '| ID | Origin / Tier | Verified Claim | Source | Period / Scope | Confidence | URL |'
|
|
1034
|
+
: '| 编号 | 来源级别 | 核验事实与数据 | 一手出处 | 时间 / 口径 | 核验状态 | 原文链接 |')
|
|
1035
|
+
: (en
|
|
1036
|
+
? '| ID | Verified Claim | Source | Period / Scope | Confidence | URL |'
|
|
1037
|
+
: '| 编号 | 核验事实与数据 | 一手出处 | 时间 / 口径 | 核验状态 | 原文链接 |'),
|
|
1038
|
+
hasOriginOrTier
|
|
1039
|
+
? '| --- | --- | --- | --- | --- | --- | --- |'
|
|
1040
|
+
: '| --- | --- | --- | --- | --- | --- |',
|
|
433
1041
|
]
|
|
434
1042
|
for (const e of ledger) {
|
|
435
1043
|
const esc = (v) => String(v ?? '').replace(/\|/g, '\\|').replace(/\s+/g, ' ').trim()
|
|
436
1044
|
const periodScope = [e.date, e.scope].filter(Boolean).join(' · ') || '—'
|
|
437
1045
|
const link = e.url ? `[link](${e.url})` : '—'
|
|
438
|
-
|
|
1046
|
+
if (hasOriginOrTier) {
|
|
1047
|
+
const tag = originShortTag(e, en) || (e.tier ? `T${e.tier}` : '—')
|
|
1048
|
+
lines.push(`| ${esc(e.id)} | ${esc(tag)} | ${esc(e.claim)} | ${esc(e.source)} | ${esc(periodScope)} | ${esc(confidenceLabel(e.confidence, en))} | ${link} |`)
|
|
1049
|
+
} else {
|
|
1050
|
+
lines.push(`| ${esc(e.id)} | ${esc(e.claim)} | ${esc(e.source)} | ${esc(periodScope)} | ${esc(confidenceLabel(e.confidence, en))} | ${link} |`)
|
|
1051
|
+
}
|
|
439
1052
|
}
|
|
440
1053
|
lines.push('')
|
|
441
1054
|
return lines.join('\n')
|
|
442
1055
|
}
|
|
443
1056
|
|
|
1057
|
+
/**
|
|
1058
|
+
* Mode C 混合资料包 × 外部权威对标补充策划器:
|
|
1059
|
+
* 诊断用户本地 Word / Excel / PDF / 照片已覆盖维度与缺失的外部权威基准(行业规模、竞品财报、政策标准、风险反方),
|
|
1060
|
+
* 自动产出带 `site:` 的精准权威检索式与不冲突的顺延编号 `nextEvidenceId`。
|
|
1061
|
+
*/
|
|
1062
|
+
export function buildHybridEnrichmentPlan(options = {}) {
|
|
1063
|
+
const topic = cleanText(options.topic ?? options.title ?? 'Business Report', 140)
|
|
1064
|
+
const instructions = cleanText(options.instructions || '', 400)
|
|
1065
|
+
const langEn = String(options.lang || 'zh').toLowerCase() === 'en'
|
|
1066
|
+
const localAssets = options.localAssets || {}
|
|
1067
|
+
const localEvidence = Array.isArray(options.localEvidence) ? options.localEvidence : []
|
|
1068
|
+
|
|
1069
|
+
const sheets = Array.isArray(localAssets.excelSheets) ? localAssets.excelSheets : []
|
|
1070
|
+
const docs = Array.isArray(localAssets.docSections) ? localAssets.docSections : []
|
|
1071
|
+
const photos = Array.isArray(localAssets.photos) ? localAssets.photos : []
|
|
1072
|
+
|
|
1073
|
+
const localText = [
|
|
1074
|
+
topic,
|
|
1075
|
+
instructions,
|
|
1076
|
+
...sheets.map((s) => `${s.sheetName || ''} ${(s.headers || []).join(' ')}`),
|
|
1077
|
+
...docs.map((d) => `${d.heading || ''} ${(d.summaryBullets || []).join(' ')}`),
|
|
1078
|
+
].join(' ')
|
|
1079
|
+
|
|
1080
|
+
const queryPack = buildAuthoritativeQueryPack({
|
|
1081
|
+
topic,
|
|
1082
|
+
context: localText,
|
|
1083
|
+
lang: langEn ? 'en' : 'zh',
|
|
1084
|
+
preferredSources: options.preferredSources,
|
|
1085
|
+
blockedDomains: options.blockedDomains,
|
|
1086
|
+
})
|
|
1087
|
+
|
|
1088
|
+
const hasFinancials = sheets.length > 0 || /营收|收入|毛利|成本|预算|财报|ARR|revenue|cost|margin|budget|kpi/i.test(localText)
|
|
1089
|
+
const hasRoadmap = sheets.some((s) => s.recommendedChartKind === 'gantt') || /排期|路线图|里程碑|Q[1-4]|roadmap|timeline|milestone/i.test(localText)
|
|
1090
|
+
const hasMarketSize = /TAM|SAM|SOM|市场规模|渗透率|CAGR|market size|penetration/i.test(localText)
|
|
1091
|
+
const hasCompetitors = /竞品|对手|友商|市场份额|competitor|peer|benchmark|market share/i.test(localText)
|
|
1092
|
+
const hasPolicy = /政策|法规|标准|合规|监管|policy|regulation|standard|compliance/i.test(localText)
|
|
1093
|
+
|
|
1094
|
+
const localCoverage = {
|
|
1095
|
+
internalFinancialOrOpsData: hasFinancials,
|
|
1096
|
+
internalRoadmap: hasRoadmap,
|
|
1097
|
+
internalPhotos: photos.length,
|
|
1098
|
+
internalDocSections: docs.length,
|
|
1099
|
+
internalSheets: sheets.length,
|
|
1100
|
+
localEvidenceCount: localEvidence.length,
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
const missingPillars = []
|
|
1104
|
+
if (!hasMarketSize) {
|
|
1105
|
+
missingPillars.push({
|
|
1106
|
+
pillar: 'macro-market-tam',
|
|
1107
|
+
priority: 'high',
|
|
1108
|
+
title: langEn ? 'Authoritative Industry TAM / CAGR Baseline' : '权威行业市场规模与增速基线(宏观对标)',
|
|
1109
|
+
targetTier: 'Tier 1–2',
|
|
1110
|
+
recommendedLayout: 'tam / chart-split',
|
|
1111
|
+
query: queryPack.rounds[0].queries[0],
|
|
1112
|
+
})
|
|
1113
|
+
}
|
|
1114
|
+
if (!hasCompetitors) {
|
|
1115
|
+
missingPillars.push({
|
|
1116
|
+
pillar: 'peer-benchmark',
|
|
1117
|
+
priority: 'high',
|
|
1118
|
+
title: langEn ? 'Listed Peer & Competitive Benchmark' : '头部竞品财报与同口径行业基准对比',
|
|
1119
|
+
targetTier: 'Tier 1–2',
|
|
1120
|
+
recommendedLayout: 'harvey / dumbbell / comparison',
|
|
1121
|
+
query: queryPack.rounds[1].queries[0],
|
|
1122
|
+
})
|
|
1123
|
+
}
|
|
1124
|
+
if (!hasPolicy) {
|
|
1125
|
+
missingPillars.push({
|
|
1126
|
+
pillar: 'policy-standards',
|
|
1127
|
+
priority: 'medium',
|
|
1128
|
+
title: langEn ? 'Official Policy, Standards & Compliance Catalysts' : '官方政策文件、行业标准与合规催化节点',
|
|
1129
|
+
targetTier: 'Tier 1',
|
|
1130
|
+
recommendedLayout: 'process[timeline] / callout',
|
|
1131
|
+
query: queryPack.rounds[0].queries[1],
|
|
1132
|
+
})
|
|
1133
|
+
}
|
|
1134
|
+
missingPillars.push({
|
|
1135
|
+
pillar: 'risk-counter-evidence',
|
|
1136
|
+
priority: 'medium',
|
|
1137
|
+
title: langEn ? 'Independent Bottlenecks, Risks & Consensus Range' : '独立第三方瓶颈分析、风险与预测区间',
|
|
1138
|
+
targetTier: 'Tier 1–2',
|
|
1139
|
+
recommendedLayout: 'comparison[issue-action] / matrix',
|
|
1140
|
+
query: queryPack.rounds[2].queries[0],
|
|
1141
|
+
})
|
|
1142
|
+
|
|
1143
|
+
let maxNum = 0
|
|
1144
|
+
for (const e of localEvidence) {
|
|
1145
|
+
const m = /^E(\d+)$/i.exec(String(e?.id || ''))
|
|
1146
|
+
if (m) maxNum = Math.max(maxNum, Number(m[1]))
|
|
1147
|
+
}
|
|
1148
|
+
const nextEvidenceId = `E${maxNum + 1}`
|
|
1149
|
+
|
|
1150
|
+
const lines = langEn
|
|
1151
|
+
? [
|
|
1152
|
+
`### Hybrid Enrichment Plan (${queryPack.domain.name})`,
|
|
1153
|
+
`- **Local Assets Indexed**: ${sheets.length} Excel/CSV sheet(s), ${docs.length} Word/PDF section(s), ${photos.length} photo(s) → \`E1..E${localEvidence.length}\` (\`origin: "local-file"\`).`,
|
|
1154
|
+
`- **Next External Evidence ID**: Start authoritative web evidence from **\`${nextEvidenceId}\`** (\`origin: "web-research"\`, \`tier: 1 | 2\`).`,
|
|
1155
|
+
`- **Authoritative Domains**: ${queryPack.domain.tier1Summary}`,
|
|
1156
|
+
`- **Suggested External Queries**:`,
|
|
1157
|
+
...missingPillars.map((p, idx) => ` ${idx + 1}. **${p.title}** (${p.targetTier}): \`${p.query}\``),
|
|
1158
|
+
]
|
|
1159
|
+
: [
|
|
1160
|
+
`### 混合资料权威外源补充计划(领域:${queryPack.domain.name})`,
|
|
1161
|
+
`- **本地资料已编目**:${sheets.length} 张数据表、${docs.length} 组文档章节、${photos.length} 张照片 → 已绑定 \`E1..E${localEvidence.length}\`(\`origin: "local-file"\`)。`,
|
|
1162
|
+
`- **外部权威顺延编号**:搜索核验后的外部权威数据请从 **\`${nextEvidenceId}\`** 开始编号(\`origin: "web-research"\`, \`tier: 1 | 2\`),零冲突双轨溯源。`,
|
|
1163
|
+
`- **推荐一手权威源**:${queryPack.domain.tier1Summary}`,
|
|
1164
|
+
`- **优先补齐的外部权威检索式**:`,
|
|
1165
|
+
...missingPillars.map((p, idx) => ` ${idx + 1}. **${p.title}**(${p.targetTier}):\`${p.query}\``),
|
|
1166
|
+
]
|
|
1167
|
+
|
|
1168
|
+
return {
|
|
1169
|
+
mode: 'hybrid-enrichment',
|
|
1170
|
+
domain: queryPack.domain,
|
|
1171
|
+
localCoverage,
|
|
1172
|
+
missingPillars,
|
|
1173
|
+
recommendedQueries: queryPack.rounds,
|
|
1174
|
+
nextEvidenceId,
|
|
1175
|
+
mergeContract: langEn
|
|
1176
|
+
? `Pass local slides/files plus external verified evidence[] (starting at ${nextEvidenceId}, origin:"web-research", tier:1|2) into ppt_create or ppt_from_office({ evidence: [...] }).`
|
|
1177
|
+
: `将核验后的外部权威 evidence[](从 ${nextEvidenceId} 起编,标注 origin:"web-research" 与 tier:1|2)直接传入 ppt_create 或 ppt_from_office({ evidence: [...] }),即可与本地资料无缝双轨融合。`,
|
|
1178
|
+
planMarkdown: lines.join('\n'),
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
|
|
444
1182
|
/**
|
|
445
1183
|
* 零资料调研策划器:给定选题(与可选已搜集的 evidence[] 账本),输出:
|
|
446
1184
|
* 1. 最佳匹配的标杆范本(20 套内置 + 工作区已吸收)与配色骨架;
|
|
447
|
-
* 2.
|
|
1185
|
+
* 2. 按 8 大专业领域自动生成的 3 轮权威 `site:` 定向检索清单(含排除营销号指令);
|
|
448
1186
|
* 3. 逐页分镜策划表(Storyboard)与证据绑定缺口诊断;
|
|
449
1187
|
* 4. 可直接展示给用户确认的 Markdown 策划方案(`planMarkdown`)。
|
|
450
1188
|
*/
|
|
@@ -468,71 +1206,23 @@ export function buildResearchPlan(options = {}) {
|
|
|
468
1206
|
}, workspaceExemplars) || CURATED_EXEMPLARS['mckinsey-strategy']
|
|
469
1207
|
}
|
|
470
1208
|
|
|
471
|
-
const evidence = normalizeEvidenceLedger(options.evidence || []
|
|
1209
|
+
const evidence = normalizeEvidenceLedger(options.evidence || [], {
|
|
1210
|
+
preferredSources: options.preferredSources,
|
|
1211
|
+
blockedDomains: options.blockedDomains,
|
|
1212
|
+
})
|
|
472
1213
|
const verified = evidence.filter((e) => e.confidence === 'verified')
|
|
473
1214
|
const estimated = evidence.filter((e) => e.confidence === 'estimated')
|
|
474
1215
|
const conflicting = evidence.filter((e) => e.confidence === 'conflicting')
|
|
475
1216
|
const unverified = evidence.filter((e) => e.confidence === 'unverified')
|
|
476
1217
|
|
|
477
|
-
const
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
],
|
|
486
|
-
requirement: 'Verify headline market size, growth rate, exact year & geographic scope from ≥2 primary sources.',
|
|
487
|
-
},
|
|
488
|
-
{
|
|
489
|
-
round: 2,
|
|
490
|
-
goal: 'Competitive Landscape & Quantitative Benchmarks',
|
|
491
|
-
queries: [
|
|
492
|
-
`"${topic}" leading companies market share benchmark comparison 2025 2026`,
|
|
493
|
-
`"${topic}" cost reduction OR efficiency improvement case study metrics`,
|
|
494
|
-
],
|
|
495
|
-
requirement: 'Collect comparable before→after metrics, unit economics, and player differentiation.',
|
|
496
|
-
},
|
|
497
|
-
{
|
|
498
|
-
round: 3,
|
|
499
|
-
goal: 'Latest Milestones, Bottlenecks & Counter-Arguments',
|
|
500
|
-
queries: [
|
|
501
|
-
`"${topic}" bottleneck OR risk OR limitation OR failed deployment 2025 2026`,
|
|
502
|
-
`"${topic}" roadmap 2026 2027 commercialization forecast`,
|
|
503
|
-
],
|
|
504
|
-
requirement: 'Record conflicting estimates honestly; switch any unsourced dimension to qualitative diagrams.',
|
|
505
|
-
},
|
|
506
|
-
]
|
|
507
|
-
: [
|
|
508
|
-
{
|
|
509
|
-
round: 1,
|
|
510
|
-
goal: '一手官方与权威基线数据(市场/政策/年报)',
|
|
511
|
-
queries: [
|
|
512
|
-
`${topic} 官方报告 OR 白皮书 OR 年报 2025 2026 数据`,
|
|
513
|
-
`${topic} 权威统计 规模 增速 口径 2025 2026`,
|
|
514
|
-
],
|
|
515
|
-
requirement: '核心规模、增速与关键指标须来自权威一手源并至少双源交叉核验,记清年份与地域口径。',
|
|
516
|
-
},
|
|
517
|
-
{
|
|
518
|
-
round: 2,
|
|
519
|
-
goal: '行业标杆对比与量化实绩(竞品/成本/提效)',
|
|
520
|
-
queries: [
|
|
521
|
-
`${topic} 头部厂商 竞争格局 市场份额 对比 2025 2026`,
|
|
522
|
-
`${topic} 标杆案例 降本 提效 实测指标`,
|
|
523
|
-
],
|
|
524
|
-
requirement: '收集同口径竞品对比、改造前后量化跃迁与单点经济模型,避免混用不可比口径。',
|
|
525
|
-
},
|
|
526
|
-
{
|
|
527
|
-
round: 3,
|
|
528
|
-
goal: '最新进展、落地瓶颈与反方风险(避免一边倒)',
|
|
529
|
-
queries: [
|
|
530
|
-
`${topic} 痛点 瓶颈 风险 局限 商业化障碍 2025 2026`,
|
|
531
|
-
`${topic} 2026 2027 路线图 发展趋势 商业化节点`,
|
|
532
|
-
],
|
|
533
|
-
requirement: '如实记录存在口径差异的预测区间;凡查不到确凿数字的维度改用定性图示,严禁编造数字。',
|
|
534
|
-
},
|
|
535
|
-
]
|
|
1218
|
+
const queryPack = buildAuthoritativeQueryPack({
|
|
1219
|
+
topic,
|
|
1220
|
+
context: `${options.context || ''} ${options.audience || ''} ${options.persona || ''}`,
|
|
1221
|
+
lang: langEn ? 'en' : 'zh',
|
|
1222
|
+
preferredSources: options.preferredSources,
|
|
1223
|
+
blockedDomains: options.blockedDomains,
|
|
1224
|
+
})
|
|
1225
|
+
const researchRounds = queryPack.rounds
|
|
536
1226
|
|
|
537
1227
|
let evCursor = 0
|
|
538
1228
|
const gaps = []
|
|
@@ -586,10 +1276,11 @@ export function buildResearchPlan(options = {}) {
|
|
|
586
1276
|
`# Research & Storyboard Plan: ${topic}`,
|
|
587
1277
|
'',
|
|
588
1278
|
`- **Matched Gold Exemplar**: \`${exemplar.id}\` (${exemplar.enName || exemplar.name}) · Theme: \`${exemplar.theme}\` · Chrome: \`${exemplar.chromeStyle}\``,
|
|
1279
|
+
`- **Authoritative Domain Pack**: \`${queryPack.domain.id}\` (${queryPack.domain.name}) · Tier 1 Priorities: ${queryPack.domain.tier1Summary}`,
|
|
589
1280
|
`- **Evidence Ledger Status**: ${evidence.length} total (${verified.length} verified, ${estimated.length} estimated, ${conflicting.length} conflicting, ${unverified.length} unverified) · **Data Gaps**: ${gaps.length} quantitative slot(s)`,
|
|
590
1281
|
'',
|
|
591
|
-
'## 1. 3-Round Retrieval & Fact-Check Checklist',
|
|
592
|
-
...researchRounds.map((r) => `- **Round ${r.round} — ${r.goal}
|
|
1282
|
+
'## 1. 3-Round Retrieval & Authoritative Fact-Check Checklist',
|
|
1283
|
+
...researchRounds.map((r) => `- **Round ${r.round} — ${r.goal}** (${r.tierTarget}): ${r.requirement} (Queries: \`${r.queries.join('` / `')}\`)`),
|
|
593
1284
|
'',
|
|
594
1285
|
'## 2. Slide-by-Slide Storyboard Blueprint',
|
|
595
1286
|
'| # | Role | Layout | Bound Evidence | Action-Title & Fill Direction |',
|
|
@@ -603,10 +1294,11 @@ export function buildResearchPlan(options = {}) {
|
|
|
603
1294
|
`# PPT 调研与分镜策划方案:${topic}`,
|
|
604
1295
|
'',
|
|
605
1296
|
`- **匹配标杆范本**:\`${exemplar.id}\`(${exemplar.name})|推荐主题 \`${exemplar.theme}\` |母版骨架 \`${exemplar.chromeStyle}\``,
|
|
1297
|
+
`- **权威信源导航**:\`${queryPack.domain.id}\`(${queryPack.domain.name})|Tier 1 首选源:${queryPack.domain.tier1Summary}`,
|
|
606
1298
|
`- **证据账本现状**:共 ${evidence.length} 条(已核验 ${verified.length} · 估算 ${estimated.length} · 口径差异 ${conflicting.length} · 待核实 ${unverified.length})|**待补量化缺口**:${gaps.length} 页`,
|
|
607
1299
|
'',
|
|
608
1300
|
'## 一、三轮定向检索与交叉核验清单',
|
|
609
|
-
...researchRounds.map((r) => `- **第 ${r.round} 轮 · ${r.goal}
|
|
1301
|
+
...researchRounds.map((r) => `- **第 ${r.round} 轮 · ${r.goal}**(${r.tierTarget}):${r.requirement}(精准检索式:\`${r.queries.join('` / `')}\`)`),
|
|
610
1302
|
'',
|
|
611
1303
|
'## 二、逐页分镜策划表(Storyboard)',
|
|
612
1304
|
'| 页码 | 叙事角色 | 推荐版式 | 绑定证据 | 结论标题方向与填空要点 |',
|
|
@@ -620,6 +1312,7 @@ export function buildResearchPlan(options = {}) {
|
|
|
620
1312
|
return {
|
|
621
1313
|
ok: true,
|
|
622
1314
|
topic,
|
|
1315
|
+
domain: queryPack.domain,
|
|
623
1316
|
exemplar: {
|
|
624
1317
|
id: exemplar.id,
|
|
625
1318
|
name: exemplar.name,
|