argo-search 2.13.0 → 2.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +93 -0
- package/README.es.md +30 -8
- package/README.ja.md +30 -8
- package/README.ko.md +30 -8
- package/README.md +511 -596
- package/README.zh.md +975 -0
- package/SKILL.md +1 -1
- package/assets/readme/counts.json +1 -1
- package/backends/domain_profiles.json +90 -6
- package/backends/engine_registry.yaml +222 -32
- package/backends/env_passthrough.txt +2 -0
- package/backends/quota_profiles.json +151 -11
- package/bin/argo +3 -0
- package/config.yaml +50 -4
- package/docs/CHANGELOG.md +45 -0
- package/docs/COMMIT_STANDARD.md +98 -0
- package/docs/ENGINE_CATALOG.md +100 -81
- package/docs/MCP_SETUP.md +1 -1
- package/docs/RELEASE_NOTES_v2.14.0.md +88 -0
- package/docs/RELEASE_NOTES_v2.14.1.md +80 -0
- package/docs/RELEASING.md +52 -0
- package/engines/specs/artic.yaml +11 -1
- package/engines/specs/cleveland.yaml +15 -1
- package/engines/specs/clinicaltrials.yaml +24 -1
- package/engines/specs/cnii.yaml +17 -1
- package/engines/specs/coingecko.yaml +10 -2
- package/engines/specs/dbpedia.yaml +32 -0
- package/engines/specs/deezer.yaml +12 -1
- package/engines/specs/doaj.yaml +14 -1
- package/engines/specs/endoflife.yaml +16 -1
- package/engines/specs/eu_opendata.yaml +11 -1
- package/engines/specs/europeana.yaml +19 -1
- package/engines/specs/feed.yaml +62 -0
- package/engines/specs/figshare.yaml +12 -1
- package/engines/specs/fourget.yaml +23 -0
- package/engines/specs/grep_app.yaml +19 -0
- package/engines/specs/hackernews.yaml +17 -1
- package/engines/specs/hal.yaml +19 -1
- package/engines/specs/hf_datasets.yaml +59 -0
- package/engines/specs/hf_papers.yaml +42 -0
- package/engines/specs/jikan.yaml +12 -10
- package/engines/specs/kaggle.yaml +46 -0
- package/engines/specs/local_baidu.yaml +5 -0
- package/engines/specs/local_seek.yaml +34 -0
- package/engines/specs/local_yandex.yaml +37 -0
- package/engines/specs/maven.yaml +61 -0
- package/engines/specs/mojeek.yaml +31 -0
- package/engines/specs/mwmbl.yaml +39 -0
- package/engines/specs/nasa_cmr.yaml +12 -1
- package/engines/specs/nuget.yaml +57 -0
- package/engines/specs/openaire.yaml +34 -0
- package/engines/specs/repology.yaml +18 -0
- package/engines/specs/tatoeba.yaml +14 -1
- package/engines/specs/tvmaze.yaml +5 -1
- package/engines/specs/usda.yaml +14 -1
- package/package.json +14 -10
- package/packages/dsh-plugin/dsh/client.js +1 -0
- package/packages/dsh-plugin/dsh/native-tools.mjs +85 -116
- package/packages/dsh-plugin/dsh/runner.js +35 -1
- package/packages/dsh-plugin/dsh/specs.js +3 -1
- package/packages/dsh-plugin/dsh/wide-research.js +5 -3
- package/packages/dsh-plugin/package.json +1 -1
- package/packages/dsh-plugin/test/client.test.js +6 -0
- package/packages/dsh-plugin/test/config.test.js +5 -1
- package/packages/dsh-plugin/test/index.test.js +3 -1
- package/packages/dsh-plugin/test/size-gate.test.js +2 -2
- package/scripts/badcase_causes.py +81 -0
- package/scripts/badcase_ledger.py +336 -19
- package/scripts/build_release_assets.sh +43 -15
- package/scripts/cache.py +3 -3
- package/scripts/check_commit_report.py +168 -0
- package/scripts/dormant_ledger.py +225 -0
- package/scripts/engine_admission.py +9 -5
- package/scripts/engine_families.py +13 -2
- package/scripts/engine_policy.py +1 -1
- package/scripts/engine_states.py +398 -8
- package/scripts/engine_status.py +31 -0
- package/scripts/engine_validate.py +224 -40
- package/scripts/engines.py +4 -34
- package/scripts/engines_base.py +53 -147
- package/scripts/engines_builders.py +2 -33
- package/scripts/engines_builders_batch12.py +168 -0
- package/scripts/engines_builders_batch16.py +13 -0
- package/scripts/engines_builders_batch9.py +0 -204
- package/scripts/engines_builders_feeds.py +148 -30
- package/scripts/engines_builders_intl.py +0 -328
- package/scripts/engines_builders_science.py +0 -85
- package/scripts/engines_builders_tech.py +0 -98
- package/scripts/engines_parsers.py +924 -0
- package/scripts/evidence_loop.py +91 -4
- package/scripts/fetch_browser.py +4 -2
- package/scripts/fetch_jsrun.py +2 -1
- package/scripts/fetch_v3.py +22 -22
- package/scripts/gen_engine_catalog.py +2 -2
- package/scripts/gen_native_tools.py +46 -18
- package/scripts/local_intent.py +175 -0
- package/scripts/local_seek.py +256 -91
- package/scripts/local_seek_adapter.py +87 -0
- package/scripts/mcp_handlers.py +124 -72
- package/scripts/mcp_server.py +1 -1
- package/scripts/mcp_tools.py +143 -61
- package/scripts/mcp_transport.py +42 -10
- package/scripts/pre-commit +68 -1
- package/scripts/recovery.py +14 -5
- package/scripts/recovery_l0.py +5 -3
- package/scripts/release.py +20 -11
- package/scripts/release_check.py +1 -1
- package/scripts/research.py +1 -1
- package/scripts/research_gates.py +3 -3
- package/scripts/route_lang.py +6 -1
- package/scripts/route_policy.py +26 -14
- package/scripts/search.py +33 -25
- package/scripts/search_cli.py +52 -6
- package/scripts/search_output.py +83 -16
- package/scripts/secret_guard.py +106 -0
- package/scripts/semantic_evidence.py +230 -15
- package/scripts/settings_page.py +80 -8
- package/scripts/source_audit.py +408 -0
- package/scripts/sync_backends.py +38 -1
- package/scripts/wechat_article.py +5 -3
- package/scripts/wide_research.py +4 -1
- package/scripts/x_article_fetch.py +2 -1
- package/sub-skills/local-search/parsers.py +6 -1
- package/sub-skills/local-seek/scripts/seek.py +390 -24
- package/sub-skills/local-seek/scripts/seek_fts.py +28 -9
- package/sub-skills/local-seek/scripts/seek_rank.py +64 -1
- package/README.en.md +0 -814
- package/engines/specs/cinii.yaml +0 -44
- package/scripts/image_vision/vision_probe +0 -0
package/scripts/engines_base.py
CHANGED
|
@@ -17,7 +17,7 @@ import engine_states as _st # 失败归因词表唯一真源
|
|
|
17
17
|
|
|
18
18
|
import serp_kill_log # noqa: E402 守卫接线+误杀账本(2026-10-10 拆出,stdlib 级轻量)
|
|
19
19
|
import time
|
|
20
|
-
import urllib.error
|
|
20
|
+
import urllib.error, urllib.parse
|
|
21
21
|
from contextlib import contextmanager
|
|
22
22
|
from datetime import datetime, timezone
|
|
23
23
|
from pathlib import Path
|
|
@@ -237,14 +237,14 @@ def _resolve(template: list[str] | str, query: str, n: int, **extra: Any) -> lis
|
|
|
237
237
|
"""替换模板占位符。"""
|
|
238
238
|
if isinstance(template, list):
|
|
239
239
|
return [_resolve(item, query, n, **extra) for item in template]
|
|
240
|
-
s = template.replace("{query}", query).replace("{n}", str(n))
|
|
240
|
+
s = template.replace("{query_quoted}", urllib.parse.quote(str(query))).replace("{query}", query).replace("{n}", str(n))
|
|
241
|
+
if "{query_slug}" in s:
|
|
242
|
+
_slug = next((_t for _tok in re.split(r"[\s,,。/?]+", str(query)) if (_t := _tok.strip().lower()) and re.fullmatch(r"[a-z][a-z0-9.\-_]{1,30}", _t) and not any(_w in _t for _w in ("生命周期", "支持到", "eol", "support", "lifecycle", "什么时候", "停更"))), "")
|
|
243
|
+
s = s.replace("{query_slug}", _slug or urllib.parse.quote(str(query)))
|
|
241
244
|
s = s.replace("{TIMESTAMP}", str(int(time.time())))
|
|
242
|
-
if "{UUID}" in s:
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
s = s.replace(f"{{{key}}}", str(val))
|
|
246
|
-
if s.startswith("~"):
|
|
247
|
-
s = str(Path.home() / s[1:])
|
|
245
|
+
if "{UUID}" in s: s = s.replace("{UUID}", _proc_uuid())
|
|
246
|
+
for key, val in extra.items(): s = s.replace(f"{{{key}}}", str(val))
|
|
247
|
+
if s.startswith("~"): s = str(Path.home() / s[1:])
|
|
248
248
|
# env 占位符:缺失时替换为空串而非保留字面量。
|
|
249
249
|
# 保留字面量会把 `Authorization: token {GITHUB_TOKEN}` 原样发出 → 401;
|
|
250
250
|
# 空串 + 调用方过滤空头 = 未配置 key 的引擎自动退化为匿名请求。
|
|
@@ -322,67 +322,21 @@ def _coerce_field(val: Any, *, max_len: int | None = None) -> str:
|
|
|
322
322
|
|
|
323
323
|
|
|
324
324
|
def _format_url_template(template: str, item: dict) -> str:
|
|
325
|
-
"""
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
return ""
|
|
329
|
-
try:
|
|
330
|
-
return re.sub(r"\{([^}]+)\}", lambda m: vals[m.group(1)], template)
|
|
331
|
-
except Exception:
|
|
332
|
-
return ""
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
def _extract_items(data: Any, path: str) -> list:
|
|
336
|
-
"""从 JSON 按路径提取列表。path 为 . / $ / [] / 空 且 data 为 list 时直接返回。"""
|
|
337
|
-
if path in ("", ".", "$", "[]"):
|
|
338
|
-
return data if isinstance(data, list) else []
|
|
339
|
-
if not isinstance(data, dict):
|
|
340
|
-
return []
|
|
341
|
-
obj = _get_path(data, path)
|
|
342
|
-
if isinstance(obj, list):
|
|
343
|
-
return obj
|
|
344
|
-
# DBLP 等 API 在 h=1 时把 hit 收成对象而非数组
|
|
345
|
-
if isinstance(obj, dict):
|
|
346
|
-
return [obj]
|
|
347
|
-
return []
|
|
325
|
+
"""委托 engines_parsers(声明式字段映射的 URL 模板能力归属解析层)。"""
|
|
326
|
+
from engines_parsers import _format_url_template as _impl
|
|
327
|
+
return _impl(template, item)
|
|
348
328
|
|
|
349
329
|
|
|
350
330
|
def _make_field_parser(path: str, fields: dict[str, str], url_template: str | None = None,
|
|
351
|
-
max_items: int = 10
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
results = []
|
|
361
|
-
for item in items:
|
|
362
|
-
if not isinstance(item, dict):
|
|
363
|
-
continue
|
|
364
|
-
r: dict[str, Any] = {}
|
|
365
|
-
for ok, ik in fields.items():
|
|
366
|
-
if not ik:
|
|
367
|
-
continue
|
|
368
|
-
raw = _get_path(item, ik) if "." in str(ik) else item.get(ik, "")
|
|
369
|
-
if raw in ("", None) and "." not in str(ik):
|
|
370
|
-
raw = item.get(ik, "")
|
|
371
|
-
coerced = _coerce_field(raw, max_len=300 if ok == "snippet" else 500)
|
|
372
|
-
if coerced:
|
|
373
|
-
r[ok] = coerced
|
|
374
|
-
if url_template and (not r.get("url") or not str(r["url"]).startswith(("http://", "https://"))):
|
|
375
|
-
built = _format_url_template(url_template, item)
|
|
376
|
-
if built.startswith(("http://", "https://")):
|
|
377
|
-
r["url"] = built
|
|
378
|
-
else:
|
|
379
|
-
r.pop("url", None)
|
|
380
|
-
if isinstance(r.get("url"), str) and r["url"].startswith("//"):
|
|
381
|
-
r["url"] = "https:" + r["url"]
|
|
382
|
-
if r.get("title") or r.get("url"):
|
|
383
|
-
results.append(r)
|
|
384
|
-
return results[:max_items]
|
|
385
|
-
return parser
|
|
331
|
+
max_items: int = 10, templates: dict[str, str] | None = None,
|
|
332
|
+
url_item_template: str | None = None) -> Callable:
|
|
333
|
+
"""委托 engines_parsers.make_field_parser(2026-11-10 拆出,见该文件说明)。
|
|
334
|
+
|
|
335
|
+
保留本函数名是为了 engines_base 内部调用点与既有测试不变;实现已归解析层,
|
|
336
|
+
避免同一套 output_map 语义在两个文件各存一份真源。
|
|
337
|
+
"""
|
|
338
|
+
from engines_parsers import make_field_parser as _impl
|
|
339
|
+
return _impl(path, fields, url_template, max_items, templates, url_item_template)
|
|
386
340
|
|
|
387
341
|
|
|
388
342
|
def _build_cli_engine(spec: dict[str, Any]) -> Any:
|
|
@@ -800,7 +754,18 @@ def _parse_http_payload(raw: str, fmt: str, eng: str, n: int,
|
|
|
800
754
|
_get_logger().warning(f"HTTP 引擎业务错误: {eng} {env_err[:120]}")
|
|
801
755
|
return [{"error": f"{eng} {env_err}", "source": eng}]
|
|
802
756
|
limit = max(1, int(n or 5))
|
|
803
|
-
#
|
|
757
|
+
# 0. 注册响应解析器优先(spec.response.parser 显式声明,P1-2)
|
|
758
|
+
try:
|
|
759
|
+
from engines_parsers import resolve as _resolve_parsers
|
|
760
|
+
_parsers = _resolve_parsers(spec)
|
|
761
|
+
if _parsers:
|
|
762
|
+
_cur = data
|
|
763
|
+
for _p in _parsers:
|
|
764
|
+
_cur = _p(_cur, spec)
|
|
765
|
+
return _apply_url_kind(_ensure_engine_source(_cur, eng)[:limit], spec)
|
|
766
|
+
except Exception as _pe:
|
|
767
|
+
_get_logger().warning(f"注册解析器失败: {eng} {_pe}")
|
|
768
|
+
# 1. 专用 JSON 解析器兜底(DDG Instant Answer / UAPI / Semantic Scholar 等)
|
|
804
769
|
custom = _CUSTOM_JSON_PARSERS.get(eng)
|
|
805
770
|
if custom:
|
|
806
771
|
return _apply_url_kind(_ensure_engine_source(custom(data), eng)[:limit], spec)
|
|
@@ -832,7 +797,13 @@ def _parse_http_payload(raw: str, fmt: str, eng: str, n: int,
|
|
|
832
797
|
"image_license": output_map.get("item_image_license", ""),
|
|
833
798
|
# 其余图片字段(许可链接/协议版本原料/像素尺寸)见 image_ops
|
|
834
799
|
**image_output_map_fields(output_map),
|
|
835
|
-
}, url_template=output_map.get("url_template")
|
|
800
|
+
}, url_template=output_map.get("url_template") or spec.get("url_template"),
|
|
801
|
+
templates={
|
|
802
|
+
# 多字段拼接模板(2026-11-10):声明后覆盖同名单字段映射,
|
|
803
|
+
# 把原 builder 的「tombstone · 授权 CC0」这类拼接变成声明式能力。
|
|
804
|
+
k: output_map.get(k) for k in ("item_title_template", "item_summary_template")
|
|
805
|
+
},
|
|
806
|
+
url_item_template=output_map.get("item_url_template"))(data)
|
|
836
807
|
# spec 级授权常量:授权不随条目变化的源(如 NASA 公版)在 spec 上写一次
|
|
837
808
|
_lic = spec.get("image_license")
|
|
838
809
|
for r in parsed:
|
|
@@ -860,11 +831,10 @@ def _parse_http_payload(raw: str, fmt: str, eng: str, n: int,
|
|
|
860
831
|
parsed, eng, preserve=bool(spec.get("preserve_source"))
|
|
861
832
|
)[:limit],
|
|
862
833
|
spec)
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
return _ensure_engine_source(_parse_generic(data, eng, limit), eng)[:limit]
|
|
834
|
+
parsed = _parse_generic(data, eng, limit, spec)
|
|
835
|
+
return _apply_url_kind(_ensure_engine_source(
|
|
836
|
+
parsed, eng, preserve=bool(spec.get("preserve_source"))
|
|
837
|
+
)[:limit], spec)
|
|
868
838
|
|
|
869
839
|
|
|
870
840
|
# ── HTML 网页解析引擎 ─────────────────────────────────────────────────────────
|
|
@@ -1032,7 +1002,7 @@ def _build_html_engine(spec: dict[str, Any]) -> Any:
|
|
|
1032
1002
|
containers = soup.select(container_sel)
|
|
1033
1003
|
except Exception:
|
|
1034
1004
|
return []
|
|
1035
|
-
from bs4 import NavigableString
|
|
1005
|
+
from bs4 import Comment, NavigableString
|
|
1036
1006
|
|
|
1037
1007
|
def _el_text(el) -> str:
|
|
1038
1008
|
"""提取元素文本。兼容 bs4 4.13+ 将页面文本标记为 TemplateString、
|
|
@@ -1046,7 +1016,10 @@ def _build_html_engine(spec: dict[str, Any]) -> Any:
|
|
|
1046
1016
|
while stack:
|
|
1047
1017
|
node = stack.pop(0)
|
|
1048
1018
|
if isinstance(node, NavigableString):
|
|
1049
|
-
|
|
1019
|
+
# Comment 是 NavigableString 子类:搜狗把内部标记写成
|
|
1020
|
+
# <!--awbg0--> 混进结果标题(实测 2026-11-10),剥离。
|
|
1021
|
+
if not isinstance(node, Comment):
|
|
1022
|
+
parts.append(str(node))
|
|
1050
1023
|
elif hasattr(node, "contents"):
|
|
1051
1024
|
stack = node.contents + stack
|
|
1052
1025
|
return "".join(parts)
|
|
@@ -1248,78 +1221,11 @@ def _parse_xml(text: str, engine_name: str) -> list[dict[str, Any]]:
|
|
|
1248
1221
|
return results
|
|
1249
1222
|
|
|
1250
1223
|
|
|
1251
|
-
def _parse_generic(data: dict[str, Any], engine_name: str = "?",
|
|
1252
|
-
limit: int = 10) -> list[dict[str, Any]]:
|
|
1253
|
-
"""
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
- 顶层 results/items/data/works/search 等
|
|
1257
|
-
- 一层嵌套(data.results / data.value)
|
|
1258
|
-
- 二层嵌套(data.webPages.value —— 博查等 AI 搜索 API)
|
|
1259
|
-
|
|
1260
|
-
字段别名:title|name|heading;url|URL|html_url|link|href;
|
|
1261
|
-
snippet|summary|content|description|abstract。
|
|
1262
|
-
"""
|
|
1263
|
-
list_keys = (
|
|
1264
|
-
"results", "items", "value", "works", "search", "data",
|
|
1265
|
-
"organic", "webPages", "hits", "documents", "entries",
|
|
1266
|
-
)
|
|
1267
|
-
|
|
1268
|
-
def _find_items(obj: Any, depth: int = 0) -> list | None:
|
|
1269
|
-
if depth > 3 or obj is None:
|
|
1270
|
-
return None
|
|
1271
|
-
if isinstance(obj, list):
|
|
1272
|
-
# 空列表或 dict 元素列表视为结果集;纯标量列表跳过
|
|
1273
|
-
if not obj or isinstance(obj[0], dict):
|
|
1274
|
-
return obj
|
|
1275
|
-
return None
|
|
1276
|
-
if not isinstance(obj, dict):
|
|
1277
|
-
return None
|
|
1278
|
-
for key in list_keys:
|
|
1279
|
-
if key not in obj:
|
|
1280
|
-
continue
|
|
1281
|
-
found = _find_items(obj[key], depth + 1)
|
|
1282
|
-
if found is not None:
|
|
1283
|
-
return found
|
|
1284
|
-
# 浅层扫描嵌套 dict(避免深扫整棵树误抓无关数组)
|
|
1285
|
-
if depth < 2:
|
|
1286
|
-
for v in obj.values():
|
|
1287
|
-
if isinstance(v, dict):
|
|
1288
|
-
found = _find_items(v, depth + 1)
|
|
1289
|
-
if found is not None:
|
|
1290
|
-
return found
|
|
1291
|
-
return None
|
|
1292
|
-
|
|
1293
|
-
items = _find_items(data) if isinstance(data, (dict, list)) else None
|
|
1294
|
-
if not items or not isinstance(items, list):
|
|
1295
|
-
return []
|
|
1296
|
-
|
|
1297
|
-
results: list[dict[str, Any]] = []
|
|
1298
|
-
for i in items:
|
|
1299
|
-
if not isinstance(i, dict):
|
|
1300
|
-
continue
|
|
1301
|
-
title = i.get("title") or i.get("name") or i.get("heading") or i.get("Title") or ""
|
|
1302
|
-
if isinstance(title, list):
|
|
1303
|
-
title = title[0] if title else ""
|
|
1304
|
-
url = (
|
|
1305
|
-
i.get("url") or i.get("URL") or i.get("html_url")
|
|
1306
|
-
or i.get("link") or i.get("href") or ""
|
|
1307
|
-
)
|
|
1308
|
-
snippet = (
|
|
1309
|
-
i.get("snippet") or i.get("summary") or i.get("content")
|
|
1310
|
-
or i.get("description") or i.get("abstract") or ""
|
|
1311
|
-
)
|
|
1312
|
-
if isinstance(snippet, list):
|
|
1313
|
-
snippet = snippet[0] if snippet else ""
|
|
1314
|
-
score = rank_score(next((v for v in (i.get("score"), i.get("relevance_score")) if v not in (None, "")), 0.5), len(results)) # 哨兵判空:显式 0 分不得膨胀成 0.5
|
|
1315
|
-
results.append({
|
|
1316
|
-
"title": str(title)[:200],
|
|
1317
|
-
"url": str(url),
|
|
1318
|
-
"snippet": str(snippet)[:300],
|
|
1319
|
-
"score": score,
|
|
1320
|
-
"source": engine_name,
|
|
1321
|
-
})
|
|
1322
|
-
return results[:limit]
|
|
1224
|
+
def _parse_generic(data: dict[str, Any] | list, engine_name: str = "?",
|
|
1225
|
+
limit: int = 10, spec: dict[str, Any] | None = None) -> list[dict[str, Any]]:
|
|
1226
|
+
"""通用智能推断 JSON 解析(委托 engines_parsers.parse_smart_generic)。"""
|
|
1227
|
+
from engines_parsers import parse_smart_generic
|
|
1228
|
+
return parse_smart_generic(data, engine_name, limit, spec)
|
|
1323
1229
|
|
|
1324
1230
|
|
|
1325
1231
|
def _ensure_engine_source(
|
|
@@ -13,11 +13,6 @@ from engines_builders_batch9 import (
|
|
|
13
13
|
_build_jolpica_engine,
|
|
14
14
|
_build_openf1_engine,
|
|
15
15
|
_build_openligadb_engine,
|
|
16
|
-
_build_artic_engine,
|
|
17
|
-
_build_cleveland_engine,
|
|
18
|
-
_build_tvmaze_engine,
|
|
19
|
-
_build_jikan_engine,
|
|
20
|
-
_build_deezer_engine,
|
|
21
16
|
_build_listenbrainz_engine,
|
|
22
17
|
_build_egov_law_engine,
|
|
23
18
|
_build_k10plus_engine,
|
|
@@ -35,11 +30,9 @@ from engines_builders_tech import (
|
|
|
35
30
|
_build_exa_engine,
|
|
36
31
|
_build_anysearch_engine,
|
|
37
32
|
_build_wechat_sogou_engine,
|
|
38
|
-
_build_hackernews_engine,
|
|
39
33
|
_build_stackoverflow_engine,
|
|
40
34
|
_build_google_scholar_engine,
|
|
41
35
|
_build_deps_dev_engine,
|
|
42
|
-
_build_endoflife_engine,
|
|
43
36
|
_build_v2ex_engine,
|
|
44
37
|
_build_github_engine,
|
|
45
38
|
_build_bing_rss_engine,
|
|
@@ -80,6 +73,8 @@ from engines_builders_cn import (
|
|
|
80
73
|
from engines_builders_batch12 import (
|
|
81
74
|
_build_so_engine,
|
|
82
75
|
_build_shenma_engine,
|
|
76
|
+
_build_repology_engine,
|
|
77
|
+
_build_grep_app_engine,
|
|
83
78
|
)
|
|
84
79
|
|
|
85
80
|
from engines_builders_batch13 import (
|
|
@@ -123,8 +118,6 @@ from engines_builders_science import (
|
|
|
123
118
|
_build_biorxiv_engine,
|
|
124
119
|
_build_rcsb_pdb_engine,
|
|
125
120
|
_build_usgs_engine,
|
|
126
|
-
_build_nasa_cmr_engine,
|
|
127
|
-
_build_clinicaltrials_engine,
|
|
128
121
|
_build_openfda_engine,
|
|
129
122
|
)
|
|
130
123
|
from engines_builders_finance import (
|
|
@@ -157,24 +150,16 @@ from engines_builders_search import (
|
|
|
157
150
|
_build_ecosia_engine,
|
|
158
151
|
)
|
|
159
152
|
from engines_builders_intl import (
|
|
160
|
-
_build_cnii_engine,
|
|
161
153
|
_build_ndl_engine,
|
|
162
154
|
_build_kor_law_engine,
|
|
163
155
|
_build_hatena_bookmark_engine,
|
|
164
156
|
_build_dnb_engine,
|
|
165
|
-
_build_doaj_engine,
|
|
166
|
-
_build_europeana_engine,
|
|
167
|
-
_build_hal_engine,
|
|
168
|
-
_build_eu_opendata_engine,
|
|
169
157
|
_build_open_meteo_engine,
|
|
170
158
|
_build_twitter_syndication_engine,
|
|
171
159
|
_build_searchmysite_engine,
|
|
172
160
|
_build_lieu_engine,
|
|
173
161
|
_build_opensky_engine,
|
|
174
162
|
_build_electricity_maps_engine,
|
|
175
|
-
_build_usda_engine,
|
|
176
|
-
_build_tatoeba_engine,
|
|
177
|
-
_build_figshare_engine,
|
|
178
163
|
_build_tencent_kline_engine,
|
|
179
164
|
_build_qq_music_engine,
|
|
180
165
|
_build_google_news_engine,
|
|
@@ -205,7 +190,6 @@ __all__ = [
|
|
|
205
190
|
"_build_em_flow_engine",
|
|
206
191
|
"_build_exa_engine",
|
|
207
192
|
"_build_wechat_sogou_engine",
|
|
208
|
-
"_build_hackernews_engine",
|
|
209
193
|
"_build_stackoverflow_engine",
|
|
210
194
|
"_build_std_samr_engine",
|
|
211
195
|
"_build_openstd_engine",
|
|
@@ -252,11 +236,9 @@ __all__ = [
|
|
|
252
236
|
"_build_gutenberg_engine",
|
|
253
237
|
"_build_wayback_cdx_engine",
|
|
254
238
|
"_build_usgs_engine",
|
|
255
|
-
"_build_nasa_cmr_engine",
|
|
256
239
|
"_build_free_dictionary_engine",
|
|
257
240
|
"_build_baidu_baike_engine",
|
|
258
241
|
"_build_pypi_engine",
|
|
259
|
-
"_build_clinicaltrials_engine",
|
|
260
242
|
"_build_openfda_engine",
|
|
261
243
|
"_build_juejin_engine",
|
|
262
244
|
"_build_models_dev_engine",
|
|
@@ -276,24 +258,16 @@ __all__ = [
|
|
|
276
258
|
"_build_google_patents_engine",
|
|
277
259
|
"_build_marginalia_engine",
|
|
278
260
|
"_build_wiby_engine",
|
|
279
|
-
"_build_cnii_engine",
|
|
280
261
|
"_build_ndl_engine",
|
|
281
262
|
"_build_kor_law_engine",
|
|
282
263
|
"_build_hatena_bookmark_engine",
|
|
283
264
|
"_build_dnb_engine",
|
|
284
|
-
"_build_doaj_engine",
|
|
285
|
-
"_build_europeana_engine",
|
|
286
|
-
"_build_hal_engine",
|
|
287
|
-
"_build_eu_opendata_engine",
|
|
288
265
|
"_build_open_meteo_engine",
|
|
289
266
|
"_build_twitter_syndication_engine",
|
|
290
267
|
"_build_searchmysite_engine",
|
|
291
268
|
"_build_lieu_engine",
|
|
292
269
|
"_build_opensky_engine",
|
|
293
270
|
"_build_electricity_maps_engine",
|
|
294
|
-
"_build_usda_engine",
|
|
295
|
-
"_build_tatoeba_engine",
|
|
296
|
-
"_build_figshare_engine",
|
|
297
271
|
"_build_tencent_kline_engine",
|
|
298
272
|
"_build_qq_music_engine",
|
|
299
273
|
"_build_parallel_engine",
|
|
@@ -311,11 +285,6 @@ __all__ = [
|
|
|
311
285
|
"_build_jolpica_engine",
|
|
312
286
|
"_build_openf1_engine",
|
|
313
287
|
"_build_openligadb_engine",
|
|
314
|
-
"_build_artic_engine",
|
|
315
|
-
"_build_cleveland_engine",
|
|
316
|
-
"_build_tvmaze_engine",
|
|
317
|
-
"_build_jikan_engine",
|
|
318
|
-
"_build_deezer_engine",
|
|
319
288
|
"_build_listenbrainz_engine",
|
|
320
289
|
"_build_egov_law_engine",
|
|
321
290
|
"_build_k10plus_engine",
|
|
@@ -13,6 +13,7 @@ tests/test_new_source_reachability.py::_DORMANT_ALLOWLIST。
|
|
|
13
13
|
|
|
14
14
|
from __future__ import annotations
|
|
15
15
|
|
|
16
|
+
import json
|
|
16
17
|
import logging
|
|
17
18
|
import re
|
|
18
19
|
import urllib.request
|
|
@@ -101,3 +102,170 @@ def _build_shenma_engine(spec: dict[str, Any]) -> Any:
|
|
|
101
102
|
logger.warning(f"神马搜索失败: {e}")
|
|
102
103
|
return []
|
|
103
104
|
return _engine
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
# ── Repology 跨发行版包生态版本与状态真相(免认证)────────────────────
|
|
108
|
+
|
|
109
|
+
def _build_repology_engine(spec: dict[str, Any]) -> Any:
|
|
110
|
+
"""Repology 全网 Linux/UNIX 跨包管理器生态版本真相(免认证)。
|
|
111
|
+
|
|
112
|
+
覆盖 Debian、Arch、Nix、Alpine、Homebrew、Fedora 等数百个仓库的真实版本与生命周期状态。
|
|
113
|
+
"""
|
|
114
|
+
timeout = spec.get("timeout", 10)
|
|
115
|
+
|
|
116
|
+
@safe_search
|
|
117
|
+
def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
|
|
118
|
+
to = _timeout or timeout
|
|
119
|
+
cleaned = re.sub(r"[,,。?!?\s]+", " ", query or "").strip()
|
|
120
|
+
tokens = [t for t in cleaned.split(" ") if t and not any(w in t.lower() for w in ("包", "版本", "依赖", "软件", "package", "version"))]
|
|
121
|
+
q = tokens[0] if tokens else (cleaned.split(" ")[0] if cleaned else "")
|
|
122
|
+
if not q:
|
|
123
|
+
return []
|
|
124
|
+
|
|
125
|
+
import urllib.parse as up
|
|
126
|
+
url = f"https://repology.org/api/v1/projects/?search={up.quote(q)}"
|
|
127
|
+
from engines_base import _http_get_raw
|
|
128
|
+
raw = _http_get_raw(url, {"Accept": "application/json", "User-Agent": "Mozilla/5.0"}, to, engine="repology")
|
|
129
|
+
if not raw:
|
|
130
|
+
return []
|
|
131
|
+
try:
|
|
132
|
+
data = json.loads(raw)
|
|
133
|
+
except json.JSONDecodeError:
|
|
134
|
+
return []
|
|
135
|
+
if not isinstance(data, dict):
|
|
136
|
+
return []
|
|
137
|
+
|
|
138
|
+
results: list[dict[str, Any]] = []
|
|
139
|
+
for proj_name, entries in list(data.items())[:n]:
|
|
140
|
+
if not isinstance(entries, list) or not entries:
|
|
141
|
+
continue
|
|
142
|
+
newest_ver = ""
|
|
143
|
+
repos_summary = []
|
|
144
|
+
for item in entries:
|
|
145
|
+
if not isinstance(item, dict):
|
|
146
|
+
continue
|
|
147
|
+
v = item.get("version") or ""
|
|
148
|
+
repo = item.get("repo") or ""
|
|
149
|
+
status = item.get("status") or ""
|
|
150
|
+
if status == "newest" and not newest_ver:
|
|
151
|
+
newest_ver = v
|
|
152
|
+
if any(k in repo for k in ("debian", "arch", "nix", "homebrew", "alpine", "fedora", "ubuntu")):
|
|
153
|
+
if len(repos_summary) < 4:
|
|
154
|
+
repos_summary.append(f"{repo}: {v}")
|
|
155
|
+
if not newest_ver and entries:
|
|
156
|
+
newest_ver = entries[0].get("version", "?")
|
|
157
|
+
|
|
158
|
+
repo_text = " · ".join(repos_summary) if repos_summary else f"共收录于 {len(entries)} 个仓库"
|
|
159
|
+
snippet = f"最新版本: {newest_ver} | 主要发行版: {repo_text}"
|
|
160
|
+
results.append({
|
|
161
|
+
"title": f"{proj_name} (Repology 跨发行版包详情)",
|
|
162
|
+
"url": f"https://repology.org/project/{proj_name}/versions",
|
|
163
|
+
"snippet": snippet,
|
|
164
|
+
"source": "repology",
|
|
165
|
+
})
|
|
166
|
+
return results
|
|
167
|
+
return _engine
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
# ── Grep.app 全球百万 GitHub 核心代码正则检索(官方 MCP 传输免认证)─────
|
|
171
|
+
|
|
172
|
+
_GREP_APP_MCP_URL = "https://mcp.grep.app"
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def _build_grep_app_engine(spec: dict[str, Any]) -> Any:
|
|
176
|
+
"""Grep.app 全网开源代码精准检索引擎(官方 MCP 通道,免认证)。
|
|
177
|
+
|
|
178
|
+
通过官方 MCP 端点直接调用 searchGitHub,避开常规前端 WAF 挑战,
|
|
179
|
+
支持字面量代码匹配与正则搜索,返回包含仓库、文件路径与行号的真实代码片段。
|
|
180
|
+
"""
|
|
181
|
+
timeout = spec.get("timeout", 10)
|
|
182
|
+
|
|
183
|
+
@safe_search
|
|
184
|
+
def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
|
|
185
|
+
to = _timeout or timeout
|
|
186
|
+
q = (query or "").strip()
|
|
187
|
+
if not q:
|
|
188
|
+
return []
|
|
189
|
+
|
|
190
|
+
from engines_builders_tech import _parse_mcp_wire, _mcp_error_of
|
|
191
|
+
|
|
192
|
+
payload = {
|
|
193
|
+
"jsonrpc": "2.0",
|
|
194
|
+
"id": 1,
|
|
195
|
+
"method": "tools/call",
|
|
196
|
+
"params": {
|
|
197
|
+
"name": "searchGitHub",
|
|
198
|
+
"arguments": {
|
|
199
|
+
"query": q,
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
}
|
|
203
|
+
body = json.dumps(payload).encode("utf-8")
|
|
204
|
+
headers = {
|
|
205
|
+
"Content-Type": "application/json",
|
|
206
|
+
"Accept": "application/json, text/event-stream",
|
|
207
|
+
"User-Agent": (
|
|
208
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) "
|
|
209
|
+
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
|
210
|
+
),
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
req = urllib.request.Request(_GREP_APP_MCP_URL, data=body, headers=headers)
|
|
214
|
+
try:
|
|
215
|
+
with http_open(req, timeout=to, engine=spec.get("_name", "grep_app")) as resp:
|
|
216
|
+
raw = resp.read().decode("utf-8", "replace")
|
|
217
|
+
except Exception as e:
|
|
218
|
+
logger.warning(f"grep_app MCP 请求失败: {e}")
|
|
219
|
+
return []
|
|
220
|
+
|
|
221
|
+
data = _parse_mcp_wire(raw)
|
|
222
|
+
if not isinstance(data, dict):
|
|
223
|
+
return []
|
|
224
|
+
|
|
225
|
+
mcp_err = _mcp_error_of(data)
|
|
226
|
+
if mcp_err:
|
|
227
|
+
logger.warning(f"grep_app MCP 上游错误: {mcp_err}")
|
|
228
|
+
return []
|
|
229
|
+
|
|
230
|
+
result = data.get("result")
|
|
231
|
+
if not isinstance(result, dict):
|
|
232
|
+
return []
|
|
233
|
+
|
|
234
|
+
content = result.get("content") or []
|
|
235
|
+
results: list[dict[str, Any]] = []
|
|
236
|
+
|
|
237
|
+
for item in content:
|
|
238
|
+
if not isinstance(item, dict):
|
|
239
|
+
continue
|
|
240
|
+
text = item.get("text") or ""
|
|
241
|
+
if not text:
|
|
242
|
+
continue
|
|
243
|
+
|
|
244
|
+
repo_m = re.search(r"Repository:\s*(\S+)", text)
|
|
245
|
+
path_m = re.search(r"Path:\s*(\S+)", text)
|
|
246
|
+
url_m = re.search(r"URL:\s*(\S+)", text)
|
|
247
|
+
snip_m = re.search(r"Snippets:\s*(.*)", text, re.S)
|
|
248
|
+
|
|
249
|
+
repo = repo_m.group(1) if repo_m else ""
|
|
250
|
+
path = path_m.group(1) if path_m else ""
|
|
251
|
+
url = url_m.group(1) if url_m else ""
|
|
252
|
+
snippet = snip_m.group(1).strip() if snip_m else text[:250]
|
|
253
|
+
|
|
254
|
+
if not url:
|
|
255
|
+
continue
|
|
256
|
+
|
|
257
|
+
title = f"{repo}: {path}" if repo and path else (path or repo or "code snippet")
|
|
258
|
+
results.append({
|
|
259
|
+
"title": title,
|
|
260
|
+
"url": url,
|
|
261
|
+
"snippet": snippet[:350],
|
|
262
|
+
"source": "grep_app",
|
|
263
|
+
})
|
|
264
|
+
if len(results) >= n:
|
|
265
|
+
break
|
|
266
|
+
|
|
267
|
+
return results
|
|
268
|
+
|
|
269
|
+
return _engine
|
|
270
|
+
|
|
271
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""批次十六构建器(已按方案 A 架构归一退役)。
|
|
3
|
+
|
|
4
|
+
本批次所涉源已全部迁移至声明式 Spec 与通用自省推断解析器:
|
|
5
|
+
- mwmbl: engines/specs/mwmbl.yaml(type: http + response.parser: mwmbl)
|
|
6
|
+
- kaggle: engines/specs/kaggle.yaml(type: http + output_map 声明)
|
|
7
|
+
- hf_papers: engines/specs/hf_papers.yaml(type: http + 智能自省推断解析器)
|
|
8
|
+
|
|
9
|
+
本文件代码实体已全量清空退役,零运行时引用。
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|