argo-search 2.9.9 → 2.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.en.md +39 -22
  2. package/README.es.md +39 -22
  3. package/README.ja.md +38 -21
  4. package/README.ko.md +38 -21
  5. package/README.md +41 -22
  6. package/SKILL.md +13 -12
  7. package/backends/domain_profiles.json +76 -0
  8. package/backends/engine_registry.yaml +163 -7
  9. package/backends/quota_profiles.json +122 -2
  10. package/backends/source_types_cn.json +9 -0
  11. package/bin/argo +22 -1
  12. package/bin/argo.js +3 -3
  13. package/config.yaml +150 -30
  14. package/docs/ARGO_INTRO.md +4 -4
  15. package/docs/ENGINE_CATALOG.md +68 -48
  16. package/docs/MCP_SETUP.md +1 -1
  17. package/docs/RELEASE_NOTES_v2.10.0.md +85 -0
  18. package/docs/RELEASE_NOTES_v2.10.1.md +57 -0
  19. package/docs/RELEASE_NOTES_v2.9.8.md +1 -1
  20. package/docs//344/270/272/344/273/200/344/271/210/351/200/211/346/213/251argo.md +9 -9
  21. package/engines/_template_http.yaml +2 -0
  22. package/engines/specs/clawhub.yaml +16 -15
  23. package/engines/specs/deepseek1024.yaml +46 -0
  24. package/engines/specs/dsh_hub.yaml +44 -0
  25. package/engines/specs/dshopen.yaml +32 -0
  26. package/engines/specs/explainx.yaml +32 -0
  27. package/engines/specs/gbfs_nyc.yaml +6 -1
  28. package/engines/specs/metaso_doc.yaml +49 -0
  29. package/engines/specs/metaso_image.yaml +65 -0
  30. package/engines/specs/metaso_podcast.yaml +60 -0
  31. package/engines/specs/metaso_scholar.yaml +57 -0
  32. package/engines/specs/metaso_video.yaml +62 -0
  33. package/engines/specs/ncpssd.yaml +44 -0
  34. package/engines/specs/sciverse.yaml +73 -0
  35. package/engines/specs/skills_sh.yaml +32 -0
  36. package/engines/specs/skillsmp.yaml +18 -16
  37. package/package.json +4 -2
  38. package/packages/dsh-plugin/README.md +3 -2
  39. package/packages/dsh-plugin/package.json +1 -1
  40. package/packages/dsh-plugin/test/size-gate.test.js +113 -0
  41. package/scripts/adaptive.py +41 -14
  42. package/scripts/article.py +6 -1
  43. package/scripts/article_meta.py +151 -2
  44. package/scripts/bench_general_pool.py +145 -0
  45. package/scripts/candidate_envelope.py +45 -4
  46. package/scripts/charset_decode.py +127 -0
  47. package/scripts/ci_drift_gate.py +47 -24
  48. package/scripts/crawl.py +240 -74
  49. package/scripts/crawl_frontier.py +217 -0
  50. package/scripts/crawl_policy.py +174 -0
  51. package/scripts/engine_dispatch.py +23 -18
  52. package/scripts/engine_failure.py +15 -0
  53. package/scripts/engine_status.py +12 -5
  54. package/scripts/engine_validate.py +8 -0
  55. package/scripts/engines.py +15 -0
  56. package/scripts/engines_base.py +43 -15
  57. package/scripts/engines_builders.py +14 -0
  58. package/scripts/engines_builders_data.py +10 -3
  59. package/scripts/engines_builders_dsh.py +330 -0
  60. package/scripts/engines_builders_skill.py +314 -0
  61. package/scripts/evidence.py +26 -5
  62. package/scripts/fetch_v3.py +37 -5
  63. package/scripts/gen_engine_catalog.py +218 -2
  64. package/scripts/general_pool.py +162 -0
  65. package/scripts/http_client.py +38 -42
  66. package/scripts/image_ops.py +4 -0
  67. package/scripts/install.ps1 +47 -19
  68. package/scripts/install.sh +45 -20
  69. package/scripts/local_seek.py +53 -11
  70. package/scripts/matrix_search_eval.py +17 -1
  71. package/scripts/mcp_transport.py +1 -1
  72. package/scripts/ncpssd_bridge.py +123 -0
  73. package/scripts/paid_policy.py +109 -13
  74. package/scripts/pre-commit +19 -4
  75. package/scripts/query_signals.py +156 -3
  76. package/scripts/redskill/redskill_engine.py +29 -2
  77. package/scripts/release.py +398 -0
  78. package/scripts/release_check.py +209 -0
  79. package/scripts/retry_policy.py +22 -1
  80. package/scripts/robots_guard.py +26 -0
  81. package/scripts/route.py +11 -8
  82. package/scripts/route_cache.py +6 -0
  83. package/scripts/route_combo.py +37 -59
  84. package/scripts/route_domains.py +22 -3
  85. package/scripts/route_policy.py +6 -0
  86. package/scripts/search.py +13 -3
  87. package/scripts/search_cli.py +49 -0
  88. package/scripts/search_entry.py +9 -0
  89. package/scripts/search_output.py +43 -0
  90. package/scripts/search_pipeline.py +43 -3
  91. package/scripts/search_rank.py +4 -1
  92. package/scripts/serp_guard.py +11 -0
  93. package/scripts/social_engines/bilibili_engine.py +163 -26
  94. package/scripts/social_engines/reddit_engine.py +52 -51
  95. package/scripts/source_selection.py +302 -0
  96. package/scripts/url_canon.py +2 -1
  97. package/scripts/video_fetch.py +303 -0
  98. package/scripts/video_meta.py +225 -0
  99. package/scripts/video_route.py +65 -0
  100. package/scripts/watch.py +123 -0
  101. package/sub-skills/local-seek/scripts/seek.py +19 -4
  102. package/engines/specs/_cisa_kev.yaml +0 -54
  103. package/engines/specs/_osv.yaml +0 -63
  104. package/scripts/local_engines.py +0 -321
@@ -1,321 +0,0 @@
1
- #!/usr/bin/env python3
2
- """本地个性化引擎插件 — 不随公开仓库提交。
3
-
4
- 包含漏洞查询类引擎(OSV.dev + CISA KEV),因启发式杀毒检测
5
- (HEUR:HackTool/VulnScan)从公开构建器中移出。
6
- 本地文件,不提交 git;删除后对应引擎自动消失,不影响其他功能。
7
- """
8
-
9
- from __future__ import annotations
10
-
11
- import json
12
- import re
13
- import time
14
- import urllib.request
15
- from typing import Any
16
-
17
- from engines_base import safe_search, rank_score, http_open, note_failure
18
-
19
-
20
- # ── OSV.dev 开源漏洞库(免 key,必须 POST)─────────────────────────────────
21
-
22
- _OSV_ECOSYSTEM_PREFIX: dict[str, str] = {
23
- "pypi": "PyPI", "npm": "npm", "go": "Go", "crates": "crates.io",
24
- "cargo": "crates.io", "maven": "Maven", "nuget": "NuGet",
25
- "packagist": "Packagist", "composer": "Packagist",
26
- "rubygems": "RubyGems", "gem": "RubyGems", "hex": "Hex",
27
- }
28
-
29
- _OSV_NPM_HINTS: frozenset[str] = frozenset({
30
- "lodash", "react", "vue", "express", "axios", "next", "webpack",
31
- "typescript", "eslint", "vite", "jest", "moment", "jquery", "angular",
32
- "svelte", "nuxt", "rollup", "babel", "prettier", "cheerio", "socket.io",
33
- })
34
-
35
- _OSV_GO_HINTS: frozenset[str] = frozenset({
36
- "golang.org/x/net", "golang.org/x/crypto", "golang.org/x/text",
37
- "github.com/gin-gonic/gin", "github.com/gorilla/websocket",
38
- })
39
-
40
-
41
- def _osv_resolve_ecosystem(query: str) -> tuple[str, str]:
42
- q = (query or "").strip()
43
- if ":" in q:
44
- head, _, tail = q.partition(":")
45
- eco = _OSV_ECOSYSTEM_PREFIX.get(head.strip().lower())
46
- if eco and tail.strip():
47
- return tail.strip(), eco
48
- name = q
49
- if name.startswith("@") or "/" in name:
50
- if name.startswith("@"):
51
- return name, "npm"
52
- if name.startswith(("github.com/", "gitlab.com/", "golang.org/")):
53
- return name, "Go"
54
- return name, "npm"
55
- if name.lower() in _OSV_NPM_HINTS:
56
- return name, "npm"
57
- if name.lower() in _OSV_GO_HINTS:
58
- return name, "Go"
59
- return name, "PyPI"
60
-
61
-
62
- def _build_osv_engine(spec: dict[str, Any]) -> Any:
63
- """OSV.dev 漏洞查询(按包名,POST /v1/query;免 key、免限次)。"""
64
- timeout = spec.get("timeout", 15)
65
-
66
- @safe_search
67
- def _engine(query: str, n: int = 5, _timeout: float | None = None,
68
- **kwargs) -> list[dict[str, Any]]:
69
- to = _timeout or timeout
70
- q = (query or "").strip()
71
- if not q:
72
- return []
73
- if re.match(r"^CVE-\d{4}-\d{4,}$", q, re.I):
74
- return []
75
- pkg, eco = _osv_resolve_ecosystem(q)
76
- body = json.dumps({"package": {"name": pkg, "ecosystem": eco}}).encode("utf-8")
77
- req = urllib.request.Request(
78
- "https://api.osv.dev/v1/query", data=body,
79
- headers={"Content-Type": "application/json"})
80
- eng_name = spec.get("_name") or "osv"
81
- try:
82
- with http_open(req, timeout=to, engine=eng_name) as resp:
83
- data = json.loads(resp.read().decode("utf-8"))
84
- except Exception as e:
85
- if isinstance(e, (json.JSONDecodeError, UnicodeDecodeError)):
86
- note_failure(eng_name, "parse", "json_decode", str(e))
87
- import logging
88
- logging.getLogger("unified_search.engines").warning(f"OSV 失败: {e}")
89
- return []
90
- results = []
91
- for i, v in enumerate((data.get("vulns") or [])[:n]):
92
- vid = str(v.get("id") or "").strip()
93
- if not vid:
94
- continue
95
- summary = str(v.get("summary") or "").strip()
96
- affected_bits = []
97
- for aff in (v.get("affected") or [])[:2]:
98
- if not isinstance(aff, dict):
99
- continue
100
- for rng in (aff.get("ranges") or [])[:2]:
101
- if not isinstance(rng, dict):
102
- continue
103
- events = rng.get("events") or []
104
- introduced = next((e.get("introduced") for e in events
105
- if isinstance(e, dict) and e.get("introduced")), "")
106
- fixed = next((e.get("fixed") for e in events
107
- if isinstance(e, dict) and e.get("fixed")), "")
108
- if introduced or fixed:
109
- affected_bits.append(
110
- f"{introduced or '?'} ≤ 受影响 < {fixed or '未修复'}")
111
- aliases = [a for a in (v.get("aliases") or []) if a][:3]
112
- snippet = " · ".join(p for p in (
113
- summary, f"生态 {eco}",
114
- affected_bits[0] if affected_bits else "",
115
- " ".join(aliases),
116
- ) if p)[:300]
117
- results.append({
118
- "title": f"{vid} [{eco}] {summary}"[:500] or vid,
119
- "url": f"https://osv.dev/vulnerability/{vid}",
120
- "snippet": snippet,
121
- "source": "osv",
122
- "published_at": str(v.get("published") or "")[:10],
123
- "score": rank_score(0.85, i),
124
- })
125
- return results
126
- return _engine
127
-
128
-
129
- # ── CISA KEV 已知在野利用漏洞(免 key,全量文件 + 本地过滤)──────────────
130
-
131
- _KEV_CACHE: dict[str, Any] = {"at": 0.0, "items": None}
132
- _KEV_TTL_S = 6 * 3600
133
-
134
-
135
- def _kev_disk_path():
136
- try:
137
- from argo_paths import state_path
138
- return state_path("cisa_kev_cache.json")
139
- except Exception:
140
- return None
141
-
142
-
143
- def _kev_load(timeout: float) -> list[dict[str, Any]]:
144
- now = time.time()
145
- cached = _KEV_CACHE.get("items")
146
- if cached and (now - float(_KEV_CACHE.get("at") or 0)) < _KEV_TTL_S:
147
- return cached
148
- disk_p = _kev_disk_path()
149
- if disk_p is not None and disk_p.exists():
150
- try:
151
- st = disk_p.stat()
152
- if (now - st.st_mtime) < _KEV_TTL_S:
153
- disk_items = json.loads(disk_p.read_text(encoding="utf-8"))
154
- if isinstance(disk_items, list) and disk_items:
155
- _KEV_CACHE["items"] = disk_items
156
- _KEV_CACHE["at"] = st.st_mtime
157
- return disk_items
158
- except Exception:
159
- pass
160
- req = urllib.request.Request(
161
- "https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json",
162
- headers={"User-Agent": "argo-search/1.0 (+cisa-kev)", "Accept": "application/json"})
163
- try:
164
- with http_open(req, timeout=timeout, engine="cisa_kev") as resp:
165
- data = json.loads(resp.read().decode("utf-8", "replace"))
166
- except Exception as e:
167
- if isinstance(e, (json.JSONDecodeError, UnicodeDecodeError)):
168
- note_failure("cisa_kev", "parse", "json_decode", str(e))
169
- import logging
170
- logging.getLogger("unified_search.engines").warning(f"CISA KEV 失败: {e}")
171
- return cached or []
172
- items = data.get("vulnerabilities") or []
173
- if not isinstance(items, list):
174
- return cached or []
175
- _KEV_CACHE["items"] = items
176
- _KEV_CACHE["at"] = now
177
- if disk_p is not None and items:
178
- try:
179
- from argo_paths import atomic_write_json
180
- atomic_write_json(disk_p, items)
181
- except Exception:
182
- pass
183
- return items
184
-
185
-
186
- def _build_cisa_kev_engine(spec: dict[str, Any]) -> Any:
187
- """CISA KEV 在野利用漏洞目录(本地过滤全量目录)。"""
188
- timeout = spec.get("timeout", 30)
189
-
190
- @safe_search
191
- def _engine(query: str, n: int = 5, _timeout: float | None = None,
192
- **kwargs) -> list[dict[str, Any]]:
193
- to = _timeout or timeout
194
- q = (query or "").strip()
195
- if not q:
196
- return []
197
- items = _kev_load(to)
198
- if not items:
199
- return []
200
- cve_q = q.upper() if re.match(r"^CVE-\d{4}-\d{4,}$", q.strip(), re.I) else ""
201
- matched = []
202
- for v in items:
203
- if not isinstance(v, dict):
204
- continue
205
- if cve_q:
206
- if str(v.get("cveID") or "").strip().upper() == cve_q:
207
- matched.append(v)
208
- continue
209
- terms = [t for t in re.split(r"[\s,]+", q.lower()) if t]
210
- hay = " ".join(str(v.get(k) or "") for k in (
211
- "cveID", "vendorProject", "product", "vulnerabilityName",
212
- "shortDescription", "requiredAction", "cwes")).lower()
213
- if all(t in hay for t in terms):
214
- matched.append(v)
215
- matched.sort(key=lambda x: str(x.get("dateAdded") or ""), reverse=True)
216
- results = []
217
- for i, v in enumerate(matched[:n]):
218
- cve = str(v.get("cveID") or "").strip()
219
- if not cve:
220
- continue
221
- vendor = str(v.get("vendorProject") or "").strip()
222
- product = str(v.get("product") or "").strip()
223
- name = str(v.get("vulnerabilityName") or "").strip()
224
- desc = str(v.get("shortDescription") or "").strip()
225
- due = str(v.get("dueDate") or "").strip()
226
- ransom = str(v.get("knownRansomwareCampaignUse") or "").strip()
227
- bits = [b for b in (
228
- f"{vendor} {product}".strip(),
229
- f"修复期限 {due}" if due else "",
230
- "已知勒索软件利用" if ransom.lower() == "known" else "",
231
- desc,
232
- ) if b]
233
- results.append({
234
- "title": f"{cve} — {name or product or vendor}"[:500],
235
- "url": "https://www.cisa.gov/known-exploited-vulnerabilities-catalog",
236
- "snippet": " · ".join(bits)[:300],
237
- "source": "cisa_kev",
238
- "published_at": str(v.get("dateAdded") or "")[:10],
239
- "score": rank_score(0.9, i),
240
- })
241
- return results
242
- return _engine
243
-
244
-
245
- # ── 引擎声明(本地个性化配置,不提交公开仓库)────────────────────────────────
246
- #
247
- # 字段与原 engines/specs/osv.yaml、engines/specs/cisa_kev.yaml 逐项对齐——
248
- # 那两个声明已加 _ 前缀改名停用(公开仓每次启动刷两行「未知引擎类型」warning),
249
- # 元数据随之并入本文件,本机路由行为(explicit_only / family / priority / qps
250
- # 等)与改名前完全一致。
251
-
252
- _LOCAL_ENGINE_SPECS: dict[str, dict[str, Any]] = {
253
- "osv": {
254
- "type": "osv",
255
- "enabled": True,
256
- "explicit_only": True,
257
- "cost_tier": "free",
258
- "label": "OSV 开源漏洞库",
259
- "family": "security",
260
- "priority": 44,
261
- "qps": 2,
262
- "period": "second",
263
- "cost_per_call": 0.0,
264
- "cost_unit": "free",
265
- "method": "POST",
266
- "url": "https://api.osv.dev/v1/query",
267
- "timeout": 15,
268
- "canary_query": "requests",
269
- "desc": "OSV.dev 开源软件漏洞库(按包查已知漏洞与影响版本区间,免 key;生态 PyPI/npm/Go/crates 等)",
270
- "description": "OSV.dev 开源漏洞查询(按包名)",
271
- "coverage": ["security", "package"],
272
- "recommended": False,
273
- "latency_ms": 1500,
274
- "headers": {"Content-Type": "application/json"},
275
- "quality_queries": [
276
- {"query": "requests"},
277
- {"query": "lodash"},
278
- {"query": "log4j-core"},
279
- ],
280
- },
281
- "cisa_kev": {
282
- "type": "cisa_kev",
283
- "enabled": True,
284
- "explicit_only": True,
285
- "cost_tier": "free",
286
- "label": "CISA KEV 在野利用漏洞",
287
- "family": "security",
288
- "priority": 47,
289
- "qps": 1,
290
- "period": "second",
291
- "cost_per_call": 0.0,
292
- "cost_unit": "free",
293
- "timeout": 30,
294
- "canary_query": "chrome",
295
- "desc": "CISA 已知被在野利用漏洞目录(官方确认已被实际攻击利用的 CVE;全量 1.35MB 本地过滤)",
296
- "description": "CISA KEV 在野利用漏洞目录",
297
- "coverage": ["security"],
298
- "recommended": False,
299
- "latency_ms": 4000,
300
- "quality_queries": [
301
- {"query": "chrome"},
302
- {"query": "CVE-2021-44228"},
303
- ],
304
- },
305
- }
306
-
307
-
308
- def register(builders: dict[str, Any], engine_specs: dict[str, Any]) -> None:
309
- """将本地引擎注册到全局 builders 和 engine_specs 中。
310
-
311
- 在 engines.py 的 _load_registry() 中、构建 registry 之前调用。
312
- 文件不存在时 engines.py 跳过 import,不影响公开仓库。
313
- 外置 spec(engines/specs/*.yaml)已有的字段保留,不抹除 explicit_only/family 等元数据。
314
- """
315
- builders["osv"] = _build_osv_engine
316
- builders["cisa_kev"] = _build_cisa_kev_engine
317
- for name, spec in _LOCAL_ENGINE_SPECS.items():
318
- base = dict(engine_specs.get(name) or {})
319
- for k, v in spec.items():
320
- base.setdefault(k, v)
321
- engine_specs[name] = base