argo-search 2.14.0 → 2.15.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 (207) hide show
  1. package/AGENTS.md +8 -6
  2. package/README.es.md +56 -824
  3. package/README.ja.md +55 -825
  4. package/README.ko.md +55 -823
  5. package/README.md +128 -868
  6. package/README.zh.md +206 -0
  7. package/SKILL.md +17 -18
  8. package/assets/readme/counts.json +1 -1
  9. package/assets/readme/hero.svg +23 -23
  10. package/backends/concept_vectors.bin +0 -0
  11. package/backends/domain_profiles.json +66 -0
  12. package/backends/engine_concept_vectors.json +1525 -1525
  13. package/backends/engine_registry.yaml +193 -46
  14. package/backends/quota_profiles.json +110 -0
  15. package/bin/argo +30 -17
  16. package/config.yaml +196 -36
  17. package/docs/ADDING_NEW_ENGINE.md +10 -0
  18. package/docs/ARGO_INTRO.md +1 -1
  19. package/docs/CHANGELOG.md +45 -0
  20. package/docs/ENGINE_CATALOG.md +128 -112
  21. package/docs/MCP_SETUP.md +2 -2
  22. package/docs/RELEASE_NOTES_v2.14.0.md +12 -1
  23. package/docs/RELEASE_NOTES_v2.14.1.md +80 -0
  24. package/docs/RELEASE_NOTES_v2.15.0.md +50 -0
  25. package/docs/RELEASING.md +53 -1
  26. package/engines/specs/ai_labs.yaml +89 -0
  27. package/engines/specs/artic.yaml +11 -1
  28. package/engines/specs/bilibili_hot.yaml +11 -1
  29. package/engines/specs/brave.yaml +3 -3
  30. package/engines/specs/cisa_alerts.yaml +40 -0
  31. package/engines/specs/cleveland.yaml +15 -1
  32. package/engines/specs/clinicaltrials.yaml +16 -1
  33. package/engines/specs/cn_ai_news.yaml +10 -8
  34. package/engines/specs/cnii.yaml +15 -4
  35. package/engines/specs/deezer.yaml +12 -1
  36. package/engines/specs/digup.yaml +11 -6
  37. package/engines/specs/doaj.yaml +14 -1
  38. package/engines/specs/douyin_hot.yaml +11 -1
  39. package/engines/specs/dw_news.yaml +4 -2
  40. package/engines/specs/endoflife.yaml +16 -1
  41. package/engines/specs/eng_blogs.yaml +63 -0
  42. package/engines/specs/eu_opendata.yaml +11 -1
  43. package/engines/specs/europeana.yaml +22 -5
  44. package/engines/specs/feed.yaml +62 -0
  45. package/engines/specs/felo.yaml +3 -3
  46. package/engines/specs/figshare.yaml +12 -1
  47. package/engines/specs/firecrawl.yaml +3 -0
  48. package/engines/specs/fourget.yaml +5 -2
  49. package/engines/specs/france24.yaml +6 -4
  50. package/engines/specs/fxtwitter.yaml +29 -6
  51. package/engines/specs/grepapp_mcp.yaml +62 -0
  52. package/engines/specs/guardian_rss.yaml +6 -4
  53. package/engines/specs/hackernews.yaml +17 -2
  54. package/engines/specs/hal.yaml +19 -1
  55. package/engines/specs/hf_datasets.yaml +59 -0
  56. package/engines/specs/hf_papers.yaml +17 -1
  57. package/engines/specs/itotii.yaml +13 -1
  58. package/engines/specs/jikan.yaml +12 -10
  59. package/engines/specs/kaggle.yaml +5 -3
  60. package/engines/specs/lobsters.yaml +41 -0
  61. package/engines/specs/local_seek.yaml +6 -0
  62. package/engines/specs/maven.yaml +61 -0
  63. package/engines/specs/nasa_cmr.yaml +12 -1
  64. package/engines/specs/nuget.yaml +57 -0
  65. package/engines/specs/open_meteo.yaml +1 -1
  66. package/engines/specs/redskill.yaml +2 -0
  67. package/engines/specs/searxng.yaml +4 -2
  68. package/engines/specs/sec_edgar.yaml +8 -3
  69. package/engines/specs/tatoeba.yaml +14 -1
  70. package/engines/specs/tinyfish.yaml +2 -0
  71. package/engines/specs/tinyfish_news.yaml +2 -0
  72. package/engines/specs/tinyfish_paper.yaml +2 -0
  73. package/engines/specs/toutiao_hot.yaml +11 -1
  74. package/engines/specs/train.yaml +3 -0
  75. package/engines/specs/tvmaze.yaml +5 -1
  76. package/engines/specs/twitter.yaml +4 -0
  77. package/engines/specs/unpaywall.yaml +6 -0
  78. package/engines/specs/usda.yaml +14 -1
  79. package/engines/specs/vam.yaml +17 -3
  80. package/engines/specs/weibo_hot.yaml +11 -1
  81. package/engines/specs/wolframalpha.yaml +3 -3
  82. package/engines/specs/xiaohongshu.yaml +2 -0
  83. package/engines/specs/zhihu.yaml +3 -18
  84. package/engines/specs/zhihu_kb.yaml +18 -0
  85. package/engines/specs/zhihu_questions.yaml +19 -0
  86. package/package.json +4 -2
  87. package/packages/dsh-plugin/README.md +9 -14
  88. package/packages/dsh-plugin/dsh/client.js +467 -1024
  89. package/packages/dsh-plugin/dsh/diagnostics.js +71 -20
  90. package/packages/dsh-plugin/dsh/native-tools.mjs +61 -113
  91. package/packages/dsh-plugin/dsh/runner.js +2 -0
  92. package/packages/dsh-plugin/dsh/wide-research.js +1 -1
  93. package/packages/dsh-plugin/package.json +8 -3
  94. package/packages/dsh-plugin/scripts/sync-local.mjs +87 -0
  95. package/packages/dsh-plugin/scripts/sync-local.sh +13 -1
  96. package/packages/dsh-plugin/test/diagnostics.test.js +38 -1
  97. package/packages/dsh-plugin/test/size-gate.test.js +2 -9
  98. package/scripts/adaptive.py +7 -1
  99. package/scripts/archive_run.py +112 -53
  100. package/scripts/argo_paths.py +40 -3
  101. package/scripts/badcase_ledger.py +153 -10
  102. package/scripts/build_concept_table.py +112 -55
  103. package/scripts/build_release_assets.sh +43 -15
  104. package/scripts/cache.py +5 -1
  105. package/scripts/caliber_isolation.py +60 -23
  106. package/scripts/circuit_breaker.py +56 -8
  107. package/scripts/cli_io.py +20 -2
  108. package/scripts/config_cache.py +31 -0
  109. package/scripts/daemon.py +146 -51
  110. package/scripts/dormant_ledger.py +239 -0
  111. package/scripts/engine_dispatch.py +3 -3
  112. package/scripts/engine_env.py +182 -1
  113. package/scripts/engine_families.py +50 -7
  114. package/scripts/engine_states.py +9 -51
  115. package/scripts/engine_validate.py +150 -6
  116. package/scripts/engines.py +15 -67
  117. package/scripts/engines_base.py +68 -124
  118. package/scripts/engines_builders.py +0 -51
  119. package/scripts/engines_builders_batch10.py +346 -100
  120. package/scripts/engines_builders_batch11.py +2 -75
  121. package/scripts/engines_builders_batch9.py +15 -228
  122. package/scripts/engines_builders_cn.py +0 -194
  123. package/scripts/engines_builders_feeds.py +203 -35
  124. package/scripts/engines_builders_intl.py +15 -443
  125. package/scripts/engines_builders_pixiv.py +2 -16
  126. package/scripts/engines_builders_science.py +0 -85
  127. package/scripts/engines_builders_search.py +7 -14
  128. package/scripts/engines_builders_tech.py +5 -112
  129. package/scripts/engines_builders_weather.py +236 -0
  130. package/scripts/engines_fields.py +91 -0
  131. package/scripts/engines_http.py +135 -0
  132. package/scripts/engines_mcp.py +383 -0
  133. package/scripts/engines_parsers.py +196 -27
  134. package/scripts/engines_schema_drift.py +260 -0
  135. package/scripts/evidence.py +13 -0
  136. package/scripts/evidence_loop.py +93 -5
  137. package/scripts/fetch_jsrun.py +15 -11
  138. package/scripts/fetch_v3.py +28 -28
  139. package/scripts/fulltext_store.py +42 -1
  140. package/scripts/fxtwitter_api.py +8 -7
  141. package/scripts/gen_engine_catalog.py +4 -4
  142. package/scripts/gen_native_tools.py +2 -1
  143. package/scripts/general_pool.py +15 -4
  144. package/scripts/health_check.py +1 -1
  145. package/scripts/link_source.py +65 -24
  146. package/scripts/local_intent.py +51 -15
  147. package/scripts/local_seek.py +37 -4
  148. package/scripts/local_seek_adapter.py +57 -17
  149. package/scripts/mcp_handlers.py +173 -99
  150. package/scripts/mcp_handlers_surface.py +6 -18
  151. package/scripts/mcp_server.py +1 -1
  152. package/scripts/mcp_tools.py +143 -61
  153. package/scripts/mcp_transport.py +42 -10
  154. package/scripts/min_version_scan.py +7 -3
  155. package/scripts/network_aware.py +7 -13
  156. package/scripts/pre-commit +57 -31
  157. package/scripts/query_understanding.py +30 -6
  158. package/scripts/quota.py +6 -1
  159. package/scripts/rank_signals.py +9 -0
  160. package/scripts/recompute.py +15 -5
  161. package/scripts/recovery.py +21 -15
  162. package/scripts/release.py +29 -32
  163. package/scripts/release_check.py +6 -26
  164. package/scripts/replay_eval.py +2 -2
  165. package/scripts/research_cli.py +40 -0
  166. package/scripts/research_notes.py +368 -0
  167. package/scripts/route.py +32 -70
  168. package/scripts/route_audit.py +259 -0
  169. package/scripts/route_combo.py +10 -4
  170. package/scripts/route_domains.py +150 -23
  171. package/scripts/route_lang.py +20 -7
  172. package/scripts/route_log.py +26 -9
  173. package/scripts/route_policy.py +91 -7
  174. package/scripts/route_telemetry_export.py +199 -0
  175. package/scripts/rrf_classic.py +5 -22
  176. package/scripts/search.py +2 -1
  177. package/scripts/search_attribution.py +33 -10
  178. package/scripts/search_cli.py +44 -7
  179. package/scripts/search_entry.py +5 -1
  180. package/scripts/search_output.py +5 -4
  181. package/scripts/search_pipeline.py +12 -0
  182. package/scripts/search_rank.py +21 -11
  183. package/scripts/secret_guard.py +106 -0
  184. package/scripts/semantic_evidence.py +539 -117
  185. package/scripts/settings_page.py +83 -11
  186. package/scripts/social_engines/xiaohongshu_engine.py +2 -1
  187. package/scripts/social_engines/zhihu_engine.py +251 -43
  188. package/scripts/sogou_weixin_browser.py +5 -6
  189. package/scripts/source_audit.py +77 -0
  190. package/scripts/source_ledger.py +2 -15
  191. package/scripts/source_selection.py +45 -20
  192. package/scripts/straggler_policy.py +1 -2
  193. package/scripts/sync_backends.py +24 -0
  194. package/scripts/tfidf_router.py +23 -11
  195. package/scripts/time_utils.py +54 -1
  196. package/scripts/train.py +68 -2
  197. package/scripts/usage_log.py +26 -1
  198. package/sub-skills/argo-wide-research/SKILL.md +68 -0
  199. package/sub-skills/ego-search/SKILL.md +1 -1
  200. package/sub-skills/local-seek/scripts/seek_fts.py +67 -4
  201. package/README.en.md +0 -826
  202. package/scripts/caliber_dedupe.py +0 -66
  203. package/scripts/engines_builders_batch16.py +0 -186
  204. package/scripts/health_probe.py +0 -253
  205. package/scripts/image_vision/vision_probe +0 -0
  206. package/scripts/social_engines/twitter_engine.py +0 -514
  207. package/scripts/sync_installs.py +0 -29
@@ -11,16 +11,25 @@
11
11
  ## 两种形态,按数据性质分(spec 的 feed_mode 决定)
12
12
 
13
13
  **hot(热榜语义)** —— 新闻 RSS 走这条。种子是固定的最近 N 条,本质是
14
- 实时流而不是检索索引,所以它**忽略 query、返回最新条目**,归入 hot_trending
15
- 族。这是仓内既有分层的要求:engine_families._REFILL_EXCLUDED_FAMILIES 把
16
- hot_trending 排除在通用 combo 回填之外,理由是「产出非『查询相关』内容,
17
- 回填只会引入噪声」。实时流应当由「热搜/今日要闻」这类域按需取用,
18
- 不参与话题检索的槽位竞争。
14
+ 实时流而不是检索索引,所以它**忽略 query、返回最新条目**。新闻 RSS 归
15
+ world_news 族(2026-11-11 从 hot_trending 移出:热榜族与百度/微博/抖音
16
+ 热榜共用 dedupe_by_family(max_per_family=2) 名额,国际新闻流不该争位)。
17
+ engine_families._REFILL_EXCLUDED_FAMILIES 同时排除了 hot_trending 与
18
+ world_news——两者都产出「非查询相关」内容,回填通用 combo 只会引入噪声。
19
+ 实时流应当由「热搜/今日要闻」这类域按需取用,不参与话题检索的槽位竞争。
20
+ world_news 还是语言绑定族:只声明 en 的源在中文查询里会被语言互斥摘除,
21
+ 这点由 route._filter_lang_bound_family 决定,与本构建器无关。
19
22
 
20
23
  **filter(本地过滤)** —— 事实核查源走这条。核查文不是实时流,而是
21
24
  「某个声明被判定为真伪」的查询型内容,用户问的是具体说法,所以本地关键词
22
25
  过滤是对的。种子里没有就返回空。
23
26
 
27
+ **多份种子(spec 的 feeds)** —— 一个引擎订多份固定窗口,过滤后合并。
28
+ 每份自己带 url、label、langs。纯中文查询不下载英文种子,纯拉丁查询
29
+ 不下载只声明了 zh 的种子;一份下载失败只丢掉这一份。label 非空时,
30
+ 标题在输出上加「出处 · 」,不改缓存里的原文。没写 feeds 的旧引擎
31
+ 仍是单份 feed_url,标题不加前缀。热榜模式仍然忽略查询、不加前缀。
32
+
24
33
  ## 匹配口径(filter 模式)
25
34
 
26
35
  拉丁词走词边界,CJK 走子串——汉字全属 \\w,\\b 对中文无效(「俄乌冲突」
@@ -57,6 +66,48 @@ _FEED_TTL_S = 300.0
57
66
  _feed_cache: dict[str, tuple[float, list[dict[str, Any]]]] = {}
58
67
 
59
68
 
69
+ def _read_disk_feed(url: str) -> list[dict[str, Any]] | None:
70
+ """跨进程轻量磁盘缓存(TTL 300s,避免 CLI 进程频繁重拉 RSS)。"""
71
+ try:
72
+ import argo_paths
73
+ p = argo_paths.state_path("feed_cache.json")
74
+ if not p.is_file():
75
+ return None
76
+ import json
77
+ with open(p, "r", encoding="utf-8") as f:
78
+ data = json.load(f)
79
+ entry = data.get(url)
80
+ if isinstance(entry, dict) and (time.time() - float(entry.get("ts", 0))) < _FEED_TTL_S:
81
+ return entry.get("items")
82
+ except Exception:
83
+ pass
84
+ return None
85
+
86
+
87
+ def _write_disk_feed(url: str, items: list[dict[str, Any]]) -> None:
88
+ """原子更新跨进程轻量磁盘缓存。"""
89
+ if not items or "example.test" in url:
90
+ return
91
+ try:
92
+ import argo_paths
93
+ import json
94
+ p = argo_paths.state_path("feed_cache.json")
95
+ data: dict[str, Any] = {}
96
+ if p.is_file():
97
+ try:
98
+ with open(p, "r", encoding="utf-8") as f:
99
+ data = json.load(f)
100
+ except Exception:
101
+ data = {}
102
+ data[url] = {"ts": time.time(), "items": items}
103
+ now = time.time()
104
+ # 清理 24h 前历史条目,防无界膨胀
105
+ data = {k: v for k, v in data.items() if isinstance(v, dict) and (now - float(v.get("ts", 0))) < 86400}
106
+ argo_paths.atomic_write_json(p, data)
107
+ except Exception:
108
+ pass
109
+
110
+
60
111
  def _clean(text: str) -> str:
61
112
  """种子字段 → 纯文本(CDATA 安全)。"""
62
113
  if not text:
@@ -176,6 +227,64 @@ def _query_terms(query: str) -> list[str]:
176
227
  return [t for t in raw if t.lower() not in _STOPWORDS]
177
228
 
178
229
 
230
+ # 多份种子时单份请求的上限。引擎级 timeout 是「这一次调用」的预算,
231
+ # 四份串行若各吃满 12s 会到 48s。单份引擎不切片,超时与改前一致。
232
+ _MULTI_SLICE_S = 8.0
233
+
234
+
235
+ def _feed_sources(spec: dict[str, Any]) -> list[dict[str, Any]]:
236
+ """声明收成种子清单。feeds 非空时用它;否则退回单份 feed_url / url。
237
+
238
+ 单份路径的 label 留空、langs 用引擎自己的声明,这样旧引擎的标题
239
+ 不加出处前缀,语言守卫仍看得到。
240
+ """
241
+ sources: list[dict[str, Any]] = []
242
+ raw = spec.get("feeds")
243
+ if isinstance(raw, list):
244
+ for item in raw:
245
+ if not isinstance(item, dict):
246
+ continue
247
+ url = str(item.get("url") or item.get("feed_url") or "").strip()
248
+ if not url:
249
+ continue
250
+ langs = item.get("langs") or []
251
+ sources.append({
252
+ "url": url,
253
+ "label": str(item.get("label") or "").strip(),
254
+ "langs": [str(x) for x in langs] if isinstance(langs, list) else [],
255
+ })
256
+ if sources:
257
+ return sources
258
+ url = str(spec.get("feed_url") or spec.get("url") or "").strip()
259
+ if not url:
260
+ return []
261
+ langs = spec.get("langs") or []
262
+ return [{
263
+ "url": url,
264
+ "label": "",
265
+ "langs": [str(x) for x in langs] if isinstance(langs, list) else [],
266
+ }]
267
+
268
+
269
+ def _feed_relevant(query: str, feed_langs: list[str]) -> bool:
270
+ """这份种子值不值得为这次查询下载。
271
+
272
+ 没声明语言的一律下载。纯中文只下载声明了 zh 的;纯拉丁跳过
273
+ 「语言集合只有 zh」的。中英混写两边都下载。
274
+ """
275
+ langs = {str(x).lower() for x in feed_langs if x}
276
+ if not langs or "*" in langs:
277
+ return True
278
+ text = query or ""
279
+ cjk = bool(_CJK_RE.search(text))
280
+ latin = bool(_LATIN_RE.search(text))
281
+ if cjk and not latin:
282
+ return "zh" in langs
283
+ if latin and not cjk:
284
+ return not (langs <= {"zh"})
285
+ return True
286
+
287
+
179
288
  def _build_rss_feed_engine(spec: dict[str, Any]) -> Any:
180
289
  """静态 RSS/Atom 种子引擎(spec 驱动,新增源只需一个 YAML)。
181
290
 
@@ -183,7 +292,9 @@ def _build_rss_feed_engine(spec: dict[str, Any]) -> Any:
183
292
  需要查询式行为的源(事实核查)显式声明 filter。
184
293
  """
185
294
  timeout = float(spec.get("timeout", 12))
186
- feed_url = spec.get("feed_url") or spec.get("url", "")
295
+ sources = _feed_sources(spec)
296
+ # 单份保持声明里的 timeout;多份每份封顶,避免一份挂起吃完整段预算。
297
+ req_timeout = timeout if len(sources) <= 1 else min(timeout, _MULTI_SLICE_S)
187
298
  name = spec.get("_name", "") or spec.get("engine_id", "") or "rss_feed"
188
299
  langs = set(spec.get("langs") or [])
189
300
  mode = str(spec.get("feed_mode") or "hot").lower()
@@ -191,9 +302,13 @@ def _build_rss_feed_engine(spec: dict[str, Any]) -> Any:
191
302
  snippet_max = int(spec.get("snippet_max", 300))
192
303
  hot_base = float(spec.get("hot_base_score", 0.55))
193
304
 
194
- def _row(it: dict[str, Any], rank: int, score: float) -> dict[str, Any]:
305
+ def _row(it: dict[str, Any], rank: int, score: float,
306
+ label: str = "") -> dict[str, Any]:
307
+ title = it["title"]
308
+ if label:
309
+ title = f"{label} · {title}"
195
310
  return {
196
- "title": it["title"],
311
+ "title": title,
197
312
  "url": it["url"],
198
313
  "snippet": it["text"][:snippet_max],
199
314
  "source": name,
@@ -201,42 +316,93 @@ def _build_rss_feed_engine(spec: dict[str, Any]) -> Any:
201
316
  "score": rank_score(score, rank),
202
317
  }
203
318
 
204
- def _load() -> list[dict[str, Any]]:
205
- hit = _feed_cache.get(feed_url)
319
+ def _load_one(url: str, one_timeout: float) -> list[dict[str, Any]]:
320
+ hit = _feed_cache.get(url)
206
321
  if hit and (time.monotonic() - hit[0]) < _FEED_TTL_S:
207
322
  return hit[1]
208
- req = urllib.request.Request(feed_url, headers={"User-Agent": _UA, "Accept": "*/*"})
209
- with http_open(req, timeout=timeout, engine=name) as resp:
210
- raw = resp.read().decode("utf-8", "replace")
211
- items = _parse_feed(raw)
212
- _feed_cache[feed_url] = (time.monotonic(), items)
213
- return items
323
+ disk_hit = _read_disk_feed(url)
324
+ if disk_hit is not None:
325
+ _feed_cache[url] = (time.monotonic(), disk_hit)
326
+ return disk_hit
327
+ if one_timeout <= 0:
328
+ return []
329
+ # 实测 lobste.rs 会偶发 TLS EOF,重试一次;仍失败只丢这一份。
330
+ last_exc: Exception | None = None
331
+ for attempt in (1, 2):
332
+ try:
333
+ req = urllib.request.Request(
334
+ url, headers={"User-Agent": _UA, "Accept": "*/*"})
335
+ with http_open(req, timeout=one_timeout, engine=name) as resp:
336
+ # utf-8-sig 去掉美联储 press_all.xml 开头的 BOM。
337
+ # ElementTree 见到 U+FEFF 会整份解析失败。
338
+ raw = resp.read().decode("utf-8-sig", "replace")
339
+ items = _parse_feed(raw)
340
+ _feed_cache[url] = (time.monotonic(), items)
341
+ _write_disk_feed(url, items)
342
+ return items
343
+ except Exception as exc:
344
+ last_exc = exc
345
+ logger.warning("rss 种子失败 %s: %s", url, last_exc)
346
+ return []
214
347
 
215
348
  @safe_search
216
349
  def _engine(query: str, n: int = 10, _timeout: float | None = None,
217
350
  **kwargs) -> list[dict[str, Any]]:
218
- items = _load()
219
- if not items:
351
+ # 热榜语义:种子即最新流,query 与语言守卫都不参与。
352
+ # 「今日要闻」没有主题词,硬筛只会返回空。
353
+ if mode == "hot":
354
+ chosen = sources
355
+ stamp = False
356
+ else:
357
+ # 引擎级 langs 不含 zh 时,纯中文查询整引擎放弃、一次都不下载。
358
+ # 多份种子要让中文源留下,引擎级 langs 必须含 zh,逐份再筛。
359
+ if langs and "zh" not in langs and _is_pure_cjk(query):
360
+ return []
361
+ chosen = [s for s in sources if _feed_relevant(query, s["langs"])]
362
+ stamp = True
363
+ if not chosen:
364
+ return []
365
+
366
+ # 多份种子时,调用方传入的 _timeout 是整次预算(search 默认 10s),
367
+ # 不是每一份的超时。单份不看它,避免改掉卫报等旧引擎的超时语义。
368
+ deadline = None
369
+ if len(sources) > 1 and _timeout:
370
+ try:
371
+ budget = float(_timeout)
372
+ except (TypeError, ValueError):
373
+ budget = 0.0
374
+ if budget > 0:
375
+ deadline = time.monotonic() + budget
376
+
377
+ rows: list[tuple[dict[str, Any], str]] = []
378
+ pending = list(chosen)
379
+ while pending:
380
+ src = pending.pop(0)
381
+ if deadline is None:
382
+ one_timeout = req_timeout
383
+ else:
384
+ left = deadline - time.monotonic()
385
+ if left < 0.4:
386
+ break
387
+ one_timeout = min(req_timeout, left / (len(pending) + 1))
388
+ label = src["label"] if stamp else ""
389
+ for it in _load_one(src["url"], one_timeout):
390
+ rows.append((it, label))
391
+ if not rows:
220
392
  return []
221
393
 
222
- # 热榜语义:种子即最新流,query 不参与过滤——返回的就是「此刻的最近条目」。
223
- # 不在这里做关键词筛选,是因为「今日要闻」这类请求本身没有主题词,
224
- # 硬筛只会返回空;话题检索应由查询驱动的引擎承担。
225
394
  if mode == "hot":
226
- return [_row(it, i, hot_base) for i, it in enumerate(items[:max(1, n)])]
395
+ return [_row(it, i, hot_base, label)
396
+ for i, (it, label) in enumerate(rows[:max(1, n)])]
227
397
 
228
- # 纯 CJK 查询打到不含 zh 的英文种子:本地过滤必然全空,直接放弃,
229
- # 把路由槽位让给中文源(同 GBIF 的 ASCII 守卫)。
230
- if langs and "zh" not in langs and _is_pure_cjk(query):
231
- return []
232
398
  terms = _query_terms(query)
233
399
  if not terms:
234
- # 全是虚词("the" / "latest news" 这类无主题词):本地过滤没有
235
- # 可依据的信号,返回空而不是把整份种子当结果交出去。
400
+ # 全是虚词("the" / "latest news"):没有可依据的主题词,
401
+ # 返回空,不把整份种子当结果交出去。
236
402
  return []
237
403
 
238
- scored: list[tuple[float, int, dict[str, Any]]] = []
239
- for rank, it in enumerate(items):
404
+ scored: list[tuple[float, int, dict[str, Any], str]] = []
405
+ for rank, (it, label) in enumerate(rows):
240
406
  low = f"{it['title']} {it['text']}".lower()
241
407
  hits = sum(1 for t in terms if _term_hit(t, low))
242
408
  if not hits:
@@ -244,12 +410,14 @@ def _build_rss_feed_engine(spec: dict[str, Any]) -> Any:
244
410
  ratio = hits / len(terms)
245
411
  if ratio < min_ratio:
246
412
  continue
247
- # 标题命中额外加权:正文顺带提到的词不如标题直指主题
248
- title_bonus = 0.15 if any(_term_hit(t, it["title"].lower()) for t in terms) else 0.0
249
- scored.append((ratio + title_bonus, rank, it))
413
+ # 标题命中额外加权:正文顺带提到的词不如标题直指主题。
414
+ # 用缓存里的原标题,不用加过出处前缀的那份。
415
+ title_bonus = 0.15 if any(
416
+ _term_hit(t, it["title"].lower()) for t in terms) else 0.0
417
+ scored.append((ratio + title_bonus, rank, it, label))
250
418
 
251
419
  scored.sort(key=lambda x: (-x[0], x[1]))
252
- return [_row(it, rank_i, min(0.6 + score * 0.2, 0.85))
253
- for score, rank_i, it in scored[:n]]
420
+ return [_row(it, rank_i, min(0.6 + score * 0.2, 0.85), label)
421
+ for score, rank_i, it, label in scored[:n]]
254
422
 
255
423
  return _engine