argo-search 2.9.9 → 2.10.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/README.en.md +24 -21
- package/README.es.md +24 -21
- package/README.ja.md +23 -20
- package/README.ko.md +23 -20
- package/README.md +26 -21
- package/SKILL.md +5 -5
- package/backends/domain_profiles.json +76 -0
- package/backends/engine_registry.yaml +161 -5
- package/backends/quota_profiles.json +122 -2
- package/bin/argo +22 -1
- package/bin/argo.js +3 -3
- package/config.yaml +128 -21
- package/docs/ARGO_INTRO.md +4 -4
- package/docs/ENGINE_CATALOG.md +64 -44
- package/docs/MCP_SETUP.md +1 -1
- package/docs/RELEASE_NOTES_v2.10.0.md +85 -0
- package/docs/RELEASE_NOTES_v2.9.8.md +1 -1
- package/docs//344/270/272/344/273/200/344/271/210/351/200/211/346/213/251argo.md +9 -9
- package/engines/specs/clawhub.yaml +16 -15
- package/engines/specs/deepseek1024.yaml +46 -0
- package/engines/specs/dsh_hub.yaml +44 -0
- package/engines/specs/dshopen.yaml +32 -0
- package/engines/specs/explainx.yaml +32 -0
- package/engines/specs/gbfs_nyc.yaml +6 -1
- package/engines/specs/metaso_doc.yaml +49 -0
- package/engines/specs/metaso_image.yaml +65 -0
- package/engines/specs/metaso_podcast.yaml +60 -0
- package/engines/specs/metaso_scholar.yaml +57 -0
- package/engines/specs/metaso_video.yaml +62 -0
- package/engines/specs/ncpssd.yaml +41 -0
- package/engines/specs/sciverse.yaml +72 -0
- package/engines/specs/skills_sh.yaml +32 -0
- package/engines/specs/skillsmp.yaml +18 -16
- package/package.json +3 -2
- package/packages/dsh-plugin/README.md +3 -2
- package/packages/dsh-plugin/package.json +1 -1
- package/packages/dsh-plugin/test/size-gate.test.js +113 -0
- package/scripts/adaptive.py +41 -14
- package/scripts/article.py +6 -1
- package/scripts/article_meta.py +151 -2
- package/scripts/bench_general_pool.py +145 -0
- package/scripts/candidate_envelope.py +45 -4
- package/scripts/charset_decode.py +127 -0
- package/scripts/crawl.py +240 -74
- package/scripts/crawl_frontier.py +217 -0
- package/scripts/crawl_policy.py +174 -0
- package/scripts/engine_dispatch.py +22 -15
- package/scripts/engine_failure.py +15 -0
- package/scripts/engine_validate.py +8 -0
- package/scripts/engines.py +10 -0
- package/scripts/engines_base.py +12 -0
- package/scripts/engines_builders.py +14 -0
- package/scripts/engines_builders_dsh.py +330 -0
- package/scripts/engines_builders_skill.py +314 -0
- package/scripts/fetch_v3.py +37 -5
- package/scripts/gen_engine_catalog.py +218 -2
- package/scripts/general_pool.py +162 -0
- package/scripts/http_client.py +38 -42
- package/scripts/image_ops.py +4 -0
- package/scripts/install.ps1 +47 -19
- package/scripts/install.sh +45 -20
- package/scripts/matrix_search_eval.py +17 -1
- package/scripts/mcp_transport.py +1 -1
- package/scripts/ncpssd_bridge.py +123 -0
- package/scripts/paid_policy.py +109 -13
- package/scripts/pre-commit +19 -4
- package/scripts/query_signals.py +156 -3
- package/scripts/redskill/redskill_engine.py +29 -2
- package/scripts/release_check.py +209 -0
- package/scripts/retry_policy.py +22 -1
- package/scripts/robots_guard.py +26 -0
- package/scripts/route.py +11 -8
- package/scripts/route_cache.py +6 -0
- package/scripts/route_combo.py +37 -59
- package/scripts/route_domains.py +4 -1
- package/scripts/route_policy.py +6 -0
- package/scripts/search.py +9 -1
- package/scripts/search_cli.py +27 -0
- package/scripts/search_entry.py +9 -0
- package/scripts/search_output.py +29 -0
- package/scripts/search_pipeline.py +39 -1
- package/scripts/search_rank.py +1 -0
- package/scripts/social_engines/bilibili_engine.py +163 -26
- package/scripts/social_engines/reddit_engine.py +52 -51
- package/scripts/source_selection.py +302 -0
- package/scripts/video_fetch.py +303 -0
- package/scripts/video_meta.py +225 -0
- package/scripts/video_route.py +65 -0
- package/scripts/watch.py +123 -0
- package/scripts/local_engines.py +0 -321
package/scripts/query_signals.py
CHANGED
|
@@ -12,8 +12,110 @@
|
|
|
12
12
|
|
|
13
13
|
from __future__ import annotations
|
|
14
14
|
|
|
15
|
+
import math
|
|
16
|
+
import re
|
|
15
17
|
from typing import Any
|
|
16
18
|
|
|
19
|
+
_CJK_RUN_RE = re.compile(r"[\u4e00-\u9fff]+")
|
|
20
|
+
_LATIN_WORD_RE = re.compile(r"[a-z0-9]+")
|
|
21
|
+
|
|
22
|
+
# 查询意图词:描述「怎么问」而不是「问什么」,不参与区分性判定。
|
|
23
|
+
# 只收高频且跨查询无区分度的词;保留 review/practice 这类可能承载主题的词,
|
|
24
|
+
# 避免把正常的结果集误判成「只命中了泛词」。
|
|
25
|
+
_INTENT_STOPWORDS = frozenset({
|
|
26
|
+
"how", "what", "why", "when", "where", "which", "who",
|
|
27
|
+
"the", "and", "or", "for", "with", "without", "vs", "versus",
|
|
28
|
+
"to", "of", "in", "on", "at", "by", "from", "about", "is", "are",
|
|
29
|
+
"best", "top", "good", "guide", "tutorial", "recommend",
|
|
30
|
+
"怎么", "如何", "什么", "为什么", "哪些", "哪个", "推荐", "教程",
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _query_terms(query: str) -> list[str]:
|
|
35
|
+
"""把查询切成「主题词」:CJK 按连续片段(≥2 字),拉丁按词(≥2 字符)。
|
|
36
|
+
|
|
37
|
+
与 `relevance_units` 的区别:那个返回 bigram,用于连续覆盖率;这里返回
|
|
38
|
+
完整片段,用于回答「这条结果到底命中了查询里的几个词」。中文「钙钛矿
|
|
39
|
+
太阳能 稳定性」是三个主题词,不是六个 bigram——按 bigram 数判定会把
|
|
40
|
+
「只命中太阳能」也算成命中两次。
|
|
41
|
+
"""
|
|
42
|
+
q = (query or "").lower()
|
|
43
|
+
terms: list[str] = []
|
|
44
|
+
for seg in _CJK_RUN_RE.findall(q):
|
|
45
|
+
# 中文意图词同样要滤:「如何 部署」若把「如何」当主题词,整批结果
|
|
46
|
+
# 都不命中它,区分性判据会误拒一条本来就答对的部署结果。
|
|
47
|
+
if len(seg) >= 2 and seg not in _INTENT_STOPWORDS:
|
|
48
|
+
terms.append(seg)
|
|
49
|
+
for word in _LATIN_WORD_RE.findall(q):
|
|
50
|
+
if len(word) >= 2 and word not in _INTENT_STOPWORDS:
|
|
51
|
+
terms.append(word)
|
|
52
|
+
seen: set[str] = set()
|
|
53
|
+
out: list[str] = []
|
|
54
|
+
for term in terms:
|
|
55
|
+
if term not in seen:
|
|
56
|
+
seen.add(term)
|
|
57
|
+
out.append(term)
|
|
58
|
+
return out
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _term_covered(term: str, text: str,
|
|
62
|
+
tokens: set[str] | None = None) -> bool:
|
|
63
|
+
"""主题词是否被文本命中:CJK 按 bigram 过半,拉丁按词干前缀。
|
|
64
|
+
|
|
65
|
+
`tokens` 由调用方按结果预算一次(同一条文本要判多个主题词),
|
|
66
|
+
不传时自行分词,保持单测可直接调用。
|
|
67
|
+
"""
|
|
68
|
+
if _CJK_RUN_RE.fullmatch(term):
|
|
69
|
+
units = [term[i:i + 2] for i in range(len(term) - 1)]
|
|
70
|
+
if not units:
|
|
71
|
+
return term in text
|
|
72
|
+
hits = sum(1 for unit in units if unit in text)
|
|
73
|
+
# 词序/分隔(「记忆 插件」vs「记忆插件」)不应让整词判负:
|
|
74
|
+
# 过半 bigram 命中即算这个词出现。
|
|
75
|
+
return hits >= max(1, math.ceil(len(units) * 0.5))
|
|
76
|
+
if tokens is None:
|
|
77
|
+
try:
|
|
78
|
+
from tfidf_router import tokenize
|
|
79
|
+
tokens = set(tokenize(text))
|
|
80
|
+
except ImportError:
|
|
81
|
+
return term in text
|
|
82
|
+
if term in tokens:
|
|
83
|
+
return True
|
|
84
|
+
# 英文词形变化:commit / commits / committed 视为同一主题词。
|
|
85
|
+
return len(term) >= 4 and any(tok.startswith(term) for tok in tokens)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _discriminative_coverage_ok(results: list[dict[str, Any]],
|
|
89
|
+
query: str) -> bool:
|
|
90
|
+
"""至少一条结果同时命中**两个**查询主题词。
|
|
91
|
+
|
|
92
|
+
2026-10-26 实测:查询「git commit」时 local_bing 返回 8 条泛化 Git 页
|
|
93
|
+
(Wikipedia / Install for Windows / Documentation),标题只命中 git,
|
|
94
|
+
旧守卫按「过半结果命中任意一个词」判定为够用 → 早停,真正对题的
|
|
95
|
+
git-commit 手册页被取消。只命中泛词(工具名)不等于回答了查询。
|
|
96
|
+
|
|
97
|
+
判据取「同一条结果命中 ≥2 个主题词」而不是提高覆盖率阈值:长查询的
|
|
98
|
+
正常结果本就只覆盖一半词,阈值一高就误杀;而「只命中一个泛词」在任何
|
|
99
|
+
查询长度下都是同一种失败。单主题词查询(如「Crawl4AI」)不适用。
|
|
100
|
+
"""
|
|
101
|
+
terms = _query_terms(query)
|
|
102
|
+
if len(terms) < 2:
|
|
103
|
+
return True
|
|
104
|
+
try:
|
|
105
|
+
from tfidf_router import tokenize
|
|
106
|
+
except ImportError:
|
|
107
|
+
return True # 分词不可用不设卡(与 query_coverage_ok 同一 fail-open)
|
|
108
|
+
for r in results:
|
|
109
|
+
if not isinstance(r, dict):
|
|
110
|
+
continue
|
|
111
|
+
text = f"{r.get('title') or ''} {r.get('snippet') or ''}".lower()
|
|
112
|
+
tokens = set(tokenize(text))
|
|
113
|
+
covered = sum(1 for term in terms
|
|
114
|
+
if _term_covered(term, text, tokens))
|
|
115
|
+
if covered >= 2:
|
|
116
|
+
return True
|
|
117
|
+
return False
|
|
118
|
+
|
|
17
119
|
|
|
18
120
|
def apply_query_rewrite(query: str) -> tuple[str, dict | None]:
|
|
19
121
|
"""统一查询改写逻辑,返回 (改写后的查询, 改写结果字典)。
|
|
@@ -110,7 +212,8 @@ def is_query_echo(results: list[dict[str, Any]], query: str) -> bool:
|
|
|
110
212
|
return len(covered_terms) == 1
|
|
111
213
|
|
|
112
214
|
|
|
113
|
-
def query_coverage_ok(results: list[dict[str, Any]], query: str
|
|
215
|
+
def query_coverage_ok(results: list[dict[str, Any]], query: str,
|
|
216
|
+
*, strict: bool = False) -> bool:
|
|
114
217
|
"""查询-结果词面覆盖守卫(fast/auto 早停质量门槛)。
|
|
115
218
|
|
|
116
219
|
2026-09-02 实测教训:fast 早停原只看计数+snippet,首引擎上游波动时
|
|
@@ -123,6 +226,15 @@ def query_coverage_ok(results: list[dict[str, Any]], query: str) -> bool:
|
|
|
123
226
|
交集同样会被拒早停(弱信号但非空);同义词改写场景(如「电脑」vs
|
|
124
227
|
「计算机」)可能多跑一个引擎,属可接受代价:宁可多一次调用,不放走
|
|
125
228
|
单引擎垃圾。
|
|
229
|
+
|
|
230
|
+
2026-10-26 补区分性判据(_discriminative_coverage_ok):只命中泛词
|
|
231
|
+
不算够用——「git commit」接受「Git - Install for Windows」是本守卫的
|
|
232
|
+
真实漏网案例。该判据只在「一条结果也没同时命中两个主题词」时拒绝,
|
|
233
|
+
不改变多数覆盖的口径,最坏代价仍是多跑一个引擎。
|
|
234
|
+
|
|
235
|
+
`strict=True`:没有任何权威信号时(authority_level/upstream_authority
|
|
236
|
+
全空或全 0),要求覆盖「明确过半」而不是「达到一半」。免费源的平庸结果
|
|
237
|
+
常在 4 条里只中 2 条就触发早停;收紧后多跑一个引擎,换更高的准确率。
|
|
126
238
|
"""
|
|
127
239
|
if not query or not query.strip():
|
|
128
240
|
return True
|
|
@@ -141,15 +253,24 @@ def query_coverage_ok(results: list[dict[str, Any]], query: str) -> bool:
|
|
|
141
253
|
single_token_titles = sum(
|
|
142
254
|
1 for r in results if len(set(tokenize(r.get("title") or ""))) <= 1
|
|
143
255
|
)
|
|
144
|
-
|
|
256
|
+
# 至少 3 条才判:单条结果本来就可能是「Paris」这种一词答案,把它当
|
|
257
|
+
# 包索引噪声会误杀(2026-10-26 实测「what is the capital of France」)。
|
|
258
|
+
if (len(results) >= 3 and len(q_set) >= 3
|
|
259
|
+
and single_token_titles * 2 > len(results)):
|
|
145
260
|
return False
|
|
146
261
|
if is_query_echo(results, query):
|
|
147
262
|
return False
|
|
263
|
+
if not _discriminative_coverage_ok(results, query):
|
|
264
|
+
return False
|
|
148
265
|
covered = 0
|
|
149
266
|
for r in results:
|
|
150
267
|
text = f"{r.get('title') or ''} {r.get('snippet') or ''}"
|
|
151
268
|
if q_set & set(tokenize(text)):
|
|
152
269
|
covered += 1
|
|
270
|
+
if strict:
|
|
271
|
+
# 明确过半:2 条要 2 条都命中,4 条要 3 条命中。没有权威信号时
|
|
272
|
+
# 不用「刚好一半」换早停。
|
|
273
|
+
return covered > len(results) / 2
|
|
153
274
|
return covered >= max(1, (len(results) + 1) // 2)
|
|
154
275
|
|
|
155
276
|
|
|
@@ -239,6 +360,22 @@ def score_clarity_ok(results: list[dict[str, Any]]) -> bool:
|
|
|
239
360
|
return (std / mean) > 0.02 # 变异系数 ≤2% 视为平坦(实测占位分全等=0)
|
|
240
361
|
|
|
241
362
|
|
|
363
|
+
def _authority_level_of(r: dict[str, Any]) -> int | None:
|
|
364
|
+
"""读单条结果的权威等级(0-4):精排写 authority_level,引擎原生写
|
|
365
|
+
upstream_authority。解析不了/越界返回 None(「没信号」不是「0」)。"""
|
|
366
|
+
for key in ("authority_level", "upstream_authority"):
|
|
367
|
+
value = r.get(key)
|
|
368
|
+
if value in (None, ""):
|
|
369
|
+
continue
|
|
370
|
+
try:
|
|
371
|
+
level = int(float(str(value).strip()))
|
|
372
|
+
except (TypeError, ValueError):
|
|
373
|
+
continue
|
|
374
|
+
if 0 <= level <= 4:
|
|
375
|
+
return level
|
|
376
|
+
return None
|
|
377
|
+
|
|
378
|
+
|
|
242
379
|
def _sufficient_internal(
|
|
243
380
|
results: list[dict[str, Any]],
|
|
244
381
|
mode: str,
|
|
@@ -255,6 +392,8 @@ def _sufficient_internal(
|
|
|
255
392
|
无交集时不许早停
|
|
256
393
|
- 两条路径都叠加平坦分守卫(score_clarity_ok):计数恰好压线且
|
|
257
394
|
分数无区分度时不许早停
|
|
395
|
+
- 权威信号(2026-10-26):任一条 authority≥3 时允许少一条即停;
|
|
396
|
+
全批无权威信号时覆盖要求收紧到「明确过半」,避免平庸免费结果早停
|
|
258
397
|
|
|
259
398
|
壳链不算「够数」(2026-10-11 热榜实测):early-stop 的两条调用
|
|
260
399
|
路径(wave-1 的 _wave1_stop → results_sufficient、wave-2 的
|
|
@@ -282,6 +421,11 @@ def _sufficient_internal(
|
|
|
282
421
|
1 for r in goods
|
|
283
422
|
if (r.get("snippet") or r.get("title") or "").strip()
|
|
284
423
|
)
|
|
424
|
+
authority_max = None
|
|
425
|
+
for r in goods:
|
|
426
|
+
level = _authority_level_of(r)
|
|
427
|
+
if level is not None and (authority_max is None or level > authority_max):
|
|
428
|
+
authority_max = level
|
|
285
429
|
if min_results is not None:
|
|
286
430
|
try:
|
|
287
431
|
need = max(1, int(min_results))
|
|
@@ -294,7 +438,16 @@ def _sufficient_internal(
|
|
|
294
438
|
# 平坦分守卫适用:占位分快照同样可能是垃圾
|
|
295
439
|
return ok and (len(goods) > need or score_clarity_ok(goods))
|
|
296
440
|
threshold = 2 if mode == "fast" else 3
|
|
441
|
+
# 高权威结果可以少一条:auto 默认 3 条,2 条 authority≥3 且覆盖通过
|
|
442
|
+
# 就停。这是 DeepSeek/官方源的结构化字段第一次参与「停不停」的判定。
|
|
443
|
+
if authority_max is not None and authority_max >= 3:
|
|
444
|
+
need = max(2, threshold - 1)
|
|
445
|
+
return (len(goods) >= need and with_snippet >= 1
|
|
446
|
+
and query_coverage_ok(goods, query))
|
|
297
447
|
ok = len(goods) >= threshold and with_snippet >= (1 if mode == "fast" else 2)
|
|
448
|
+
# 全批没有权威信号(None 或 0)时,覆盖要求明确过半;有 1-2 级弱信号
|
|
449
|
+
# 的批不额外收紧,避免把大量正常免费结果误伤。
|
|
450
|
+
strict = authority_max in (None, 0)
|
|
298
451
|
return (ok
|
|
299
|
-
and query_coverage_ok(goods, query)
|
|
452
|
+
and query_coverage_ok(goods, query, strict=strict)
|
|
300
453
|
and (len(goods) > threshold or score_clarity_ok(goods)))
|
|
@@ -57,6 +57,13 @@ RANK_LISTS = {
|
|
|
57
57
|
"today": "todayList",
|
|
58
58
|
"author": "authorList",
|
|
59
59
|
}
|
|
60
|
+
|
|
61
|
+
# 「非可安装」这个关键信息为什么进摘要前缀,而不是 metadata:
|
|
62
|
+
# argo 的 CLI builder 用 image_ops._cli_result_row 做字段白名单,只保留
|
|
63
|
+
# title/url/snippet/source/published_at + 图片字段——metadata 与 upstream
|
|
64
|
+
# **都不透传**(实测 redskill 输出带 metadata,Argo 结果里是 null)。
|
|
65
|
+
# snippet 是 CLI 引擎唯一能自由填充的字段,故把使用方式写在最前面。
|
|
66
|
+
_USAGE_PREFIX = "【小红书技能·APP 内使用】"
|
|
60
67
|
RANK_LABELS = {
|
|
61
68
|
"use": "使用人数榜",
|
|
62
69
|
"new": "7天新增榜",
|
|
@@ -216,10 +223,21 @@ def _search_all(data: dict[str, Any], query: str, n: int) -> list[dict[str, Any]
|
|
|
216
223
|
results.append({
|
|
217
224
|
"title": name,
|
|
218
225
|
"url": url,
|
|
219
|
-
"snippet": str(s.get(
|
|
226
|
+
"snippet": f"{_USAGE_PREFIX}{str(s.get('skill_description', ''))}"[:500],
|
|
220
227
|
"score": round(score, 3),
|
|
221
228
|
"source": "redskill",
|
|
222
229
|
"skill_id": sid,
|
|
230
|
+
# 小红书技能是**提示词/方法论**,不是可安装的代码包。上游数据
|
|
231
|
+
# (allSkills 52314 条)只有 skill_id / skill_name /
|
|
232
|
+
# skill_description 三个字段,**零安装地址**——实测 githubUrl /
|
|
233
|
+
# url / installUrl / repoUrl / note_id 全部为 0 命中;只有 300 条
|
|
234
|
+
# 榜单技能带 note_id。明确标注,避免用户以为「搜到就能装」。
|
|
235
|
+
"metadata": {
|
|
236
|
+
"platform": "xiaohongshu",
|
|
237
|
+
"installable": False,
|
|
238
|
+
"note_id": note,
|
|
239
|
+
"usage": "小红书站内技能:在小红书 APP 内使用,或复制描述作提示词",
|
|
240
|
+
},
|
|
223
241
|
})
|
|
224
242
|
return results
|
|
225
243
|
|
|
@@ -242,7 +260,7 @@ def _rank_list(data: dict[str, Any], rank_type: str, n: int) -> list[dict[str, A
|
|
|
242
260
|
note = item.get("note_id")
|
|
243
261
|
url = EXPLORE_URL.format(note) if note else PAGE_URL
|
|
244
262
|
|
|
245
|
-
snippet = str(item.get(
|
|
263
|
+
snippet = f"{_USAGE_PREFIX}{str(item.get('skill_description', ''))}"[:500]
|
|
246
264
|
results.append({
|
|
247
265
|
"title": item.get("skill_name", ""),
|
|
248
266
|
"url": url,
|
|
@@ -253,6 +271,15 @@ def _rank_list(data: dict[str, Any], rank_type: str, n: int) -> list[dict[str, A
|
|
|
253
271
|
"skill_id": item.get("skill_id"),
|
|
254
272
|
"use_cnt": item.get("use_cnt") if rank_type in ("use", "today") else item.get("new7_cnt"),
|
|
255
273
|
"use_users": item.get("use_users") if rank_type in ("use", "today") else None,
|
|
274
|
+
# 榜单技能有 note_id(可跳笔记),但笔记里也没有「安装包」——
|
|
275
|
+
# 小红书技能的使用入口是 APP 本身,不是下载。同 _search_all。
|
|
276
|
+
"metadata": {
|
|
277
|
+
"platform": "xiaohongshu",
|
|
278
|
+
"installable": False,
|
|
279
|
+
"note_id": note,
|
|
280
|
+
"rank": i + 1,
|
|
281
|
+
"usage": "小红书站内技能:在小红书 APP 内使用,或复制描述作提示词",
|
|
282
|
+
},
|
|
256
283
|
})
|
|
257
284
|
return results
|
|
258
285
|
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""release_check.py — 发布一致性预检(10 秒回答「这棵树能不能发」)。
|
|
3
|
+
|
|
4
|
+
## 为什么要这道预检
|
|
5
|
+
|
|
6
|
+
版本号散在 16 处声明(pyproject / package.json / dsh 插件包 / 插件市场清单 /
|
|
7
|
+
MCP Registry 清单 / ZCode 插件清单 / argo_search.__version__ / SKILL.md 前置
|
|
8
|
+
字段 / MCP 与面板源码常量 + 五语 README 的徽标),外加五语 README 的发布记录
|
|
9
|
+
行、docs/RELEASE_NOTES_v<ver>.md 与 package.json 的 files 白名单(带版本号的
|
|
10
|
+
文件名,漏改就是 npm 包里静默缺文件)。历史上 v2.9.8 漏过 README「最近更新」
|
|
11
|
+
条目、版本号清单靠人肉逐处核对——每次发版三十到四十分钟,且漏改不一定当场
|
|
12
|
+
发现(npm 包发出去了才看到 README 还是旧版)。
|
|
13
|
+
|
|
14
|
+
## 检什么(全部是结构化事实,不做散文匹配)
|
|
15
|
+
|
|
16
|
+
1. 十一处机器声明与 pyproject.toml 的 version 完全一致;
|
|
17
|
+
2. 五语 README 的徽标 `badge/version-<v>-` 与发布表行 `| **v<v>** |` 都在;
|
|
18
|
+
3. `docs/RELEASE_NOTES_v<v>.md` 存在;
|
|
19
|
+
4. package.json 的 files 白名单包含当前发布说明,且**盘上每份**发布说明都在
|
|
20
|
+
白名单里(新增 RELEASE_NOTES 忘登记 = npm 包缺文件,与版本号无关)。
|
|
21
|
+
|
|
22
|
+
不检查散文里的版本提法(「当前 2.9.9」这类句子五语各有写法,正则匹配只会
|
|
23
|
+
制造假红;结构化位置全绿即可保证对外可见的版本事实一致)。
|
|
24
|
+
|
|
25
|
+
用法:
|
|
26
|
+
python3 scripts/release_check.py # 预检,非零退出码 = 不能发
|
|
27
|
+
python3 scripts/release_check.py --root . # 指定检出根(测试用)
|
|
28
|
+
|
|
29
|
+
被 tests/test_release_consistency.py 锁进 pre-commit 快门禁:版本漂移会在
|
|
30
|
+
提交时就被拦下,而不是等发版当天。
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
from __future__ import annotations
|
|
34
|
+
|
|
35
|
+
import argparse
|
|
36
|
+
import json
|
|
37
|
+
import re
|
|
38
|
+
import sys
|
|
39
|
+
from pathlib import Path
|
|
40
|
+
|
|
41
|
+
# 十一处机器声明的相对路径(顺序即报错输出顺序)
|
|
42
|
+
JSON_DECLS = (
|
|
43
|
+
"package.json",
|
|
44
|
+
"packages/dsh-plugin/package.json",
|
|
45
|
+
"server.json",
|
|
46
|
+
"packages/argo-zcode/.zcode-plugin/plugin.json",
|
|
47
|
+
)
|
|
48
|
+
README_LANGS = ("README.md", "README.en.md", "README.ja.md", "README.ko.md", "README.es.md")
|
|
49
|
+
|
|
50
|
+
# 源码里的版本常量(正则取,避免 import 副作用)
|
|
51
|
+
SRC_DECLS = (
|
|
52
|
+
("scripts/mcp_transport.py", r'ARGO_MCP_VERSION\s*=\s*"([^"]+)"'),
|
|
53
|
+
("packages/argo-zcode/server/panel_server.mjs",
|
|
54
|
+
r'SERVER_INFO\s*=\s*\{[^}]*version:\s*"([^"]+)"'),
|
|
55
|
+
("packages/argo-zcode/ui/panel.html",
|
|
56
|
+
r'new App\(\{\s*name:\s*"argo-panel",\s*version:\s*"([^"]+)"'),
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _read(root: Path, rel: str) -> str:
|
|
61
|
+
return (root / rel).read_text(encoding="utf-8")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _safe_read(root: Path, rel: str, problems: list[str]) -> str | None:
|
|
65
|
+
"""读文件;缺失/不可读记一条问题而不是抛 traceback。
|
|
66
|
+
|
|
67
|
+
--root 指错目录(或检出被裁剪)是常见的误用,预检工具必须给一句可读的
|
|
68
|
+
话,而不是让 FileNotFoundError 穿出去——那会让「预检」本身看起来像坏了。
|
|
69
|
+
"""
|
|
70
|
+
try:
|
|
71
|
+
return _read(root, rel)
|
|
72
|
+
except OSError as e:
|
|
73
|
+
problems.append(f"{rel}: 读取失败({e.strerror or e})")
|
|
74
|
+
return None
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _pyproject_version(root: Path) -> str:
|
|
78
|
+
m = re.search(r'(?m)^version\s*=\s*"([^"]+)"', _read(root, "pyproject.toml"))
|
|
79
|
+
return m.group(1) if m else ""
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def check(root: Path) -> list[str]:
|
|
83
|
+
"""返回问题清单;空列表 = 一致。"""
|
|
84
|
+
problems: list[str] = []
|
|
85
|
+
if not (root / "pyproject.toml").is_file():
|
|
86
|
+
return [f"{root} 不像 argo 检出(缺 pyproject.toml)"]
|
|
87
|
+
ver = _pyproject_version(root)
|
|
88
|
+
if not ver:
|
|
89
|
+
return ["pyproject.toml 读不出 version(真源缺失,预检无法进行)"]
|
|
90
|
+
|
|
91
|
+
# 1) JSON 声明
|
|
92
|
+
for rel in JSON_DECLS:
|
|
93
|
+
text = _safe_read(root, rel, problems)
|
|
94
|
+
if text is None:
|
|
95
|
+
continue
|
|
96
|
+
try:
|
|
97
|
+
got = str(json.loads(text).get("version") or "")
|
|
98
|
+
except ValueError as e:
|
|
99
|
+
problems.append(f"{rel}: JSON 解析失败({e})")
|
|
100
|
+
continue
|
|
101
|
+
if got != ver:
|
|
102
|
+
problems.append(f"{rel}: {got} ≠ pyproject {ver}")
|
|
103
|
+
|
|
104
|
+
# 2) 插件市场清单(plugins[] 每个都要对上)
|
|
105
|
+
text = _safe_read(root, "packages/marketplace.json", problems)
|
|
106
|
+
if text is not None:
|
|
107
|
+
try:
|
|
108
|
+
market = json.loads(text)
|
|
109
|
+
for plugin in market.get("plugins") or []:
|
|
110
|
+
got = str(plugin.get("version") or "")
|
|
111
|
+
if got != ver:
|
|
112
|
+
problems.append(
|
|
113
|
+
f"packages/marketplace.json[{plugin.get('name')}]: {got} ≠ {ver}")
|
|
114
|
+
except (OSError, ValueError) as e:
|
|
115
|
+
problems.append(f"packages/marketplace.json: 读取失败({e})")
|
|
116
|
+
|
|
117
|
+
# 2b) MCP Registry 清单(packages[] 每条的版本也要对上)
|
|
118
|
+
text = _safe_read(root, "server.json", problems)
|
|
119
|
+
if text is not None:
|
|
120
|
+
try:
|
|
121
|
+
for pkg in json.loads(text).get("packages") or []:
|
|
122
|
+
got = str(pkg.get("version") or "")
|
|
123
|
+
if got != ver:
|
|
124
|
+
problems.append(
|
|
125
|
+
f"server.json[{pkg.get('identifier')}]: {got} ≠ {ver}")
|
|
126
|
+
except ValueError as e:
|
|
127
|
+
problems.append(f"server.json: JSON 解析失败({e})")
|
|
128
|
+
|
|
129
|
+
# 2c) 源码常量(MCP 握手自报版本、ZCode 面板版本)
|
|
130
|
+
for rel, pat in SRC_DECLS:
|
|
131
|
+
if not (root / rel).is_file():
|
|
132
|
+
continue
|
|
133
|
+
m = re.search(pat, _read(root, rel))
|
|
134
|
+
if not m:
|
|
135
|
+
problems.append(f"{rel}: 找不到版本声明")
|
|
136
|
+
elif m.group(1) != ver:
|
|
137
|
+
problems.append(f"{rel}: {m.group(1)} ≠ {ver}")
|
|
138
|
+
|
|
139
|
+
# 3) Python 包内声明(MCP/库调用方读它)
|
|
140
|
+
text = _safe_read(root, "argo_search/__init__.py", problems)
|
|
141
|
+
if text is not None:
|
|
142
|
+
m = re.search(r'(?m)^__version__\s*=\s*"([^"]+)"', text)
|
|
143
|
+
if not m:
|
|
144
|
+
problems.append("argo_search/__init__.py: 找不到 __version__")
|
|
145
|
+
elif m.group(1) != ver:
|
|
146
|
+
problems.append(f"argo_search/__init__.py: {m.group(1)} ≠ {ver}")
|
|
147
|
+
|
|
148
|
+
# 4) SKILL.md 前置字段
|
|
149
|
+
text = _safe_read(root, "SKILL.md", problems)
|
|
150
|
+
if text is not None:
|
|
151
|
+
m = re.search(r"(?m)^version:\s*(\S+)\s*$", text[:2000])
|
|
152
|
+
if not m:
|
|
153
|
+
problems.append("SKILL.md: 前置字段缺 version")
|
|
154
|
+
elif m.group(1) != ver:
|
|
155
|
+
problems.append(f"SKILL.md: {m.group(1)} ≠ {ver}")
|
|
156
|
+
|
|
157
|
+
# 5) 五语 README:徽标 + 发布表行
|
|
158
|
+
for rel in README_LANGS:
|
|
159
|
+
text = _safe_read(root, rel, problems)
|
|
160
|
+
if text is None:
|
|
161
|
+
continue
|
|
162
|
+
if f"badge/version-{ver}-" not in text:
|
|
163
|
+
problems.append(f"{rel}: 徽标不是 {ver}")
|
|
164
|
+
if f"| **v{ver}** |" not in text:
|
|
165
|
+
problems.append(f"{rel}: 发布记录表缺 | **v{ver}** | 行")
|
|
166
|
+
|
|
167
|
+
# 6) 发布说明文件 + npm files 白名单
|
|
168
|
+
notes = f"docs/RELEASE_NOTES_v{ver}.md"
|
|
169
|
+
if not (root / notes).is_file():
|
|
170
|
+
problems.append(f"{notes}: 发布说明不存在")
|
|
171
|
+
text = _safe_read(root, "package.json", problems)
|
|
172
|
+
files = []
|
|
173
|
+
if text is not None:
|
|
174
|
+
try:
|
|
175
|
+
files = json.loads(text).get("files") or []
|
|
176
|
+
except ValueError:
|
|
177
|
+
files = []
|
|
178
|
+
if notes not in files:
|
|
179
|
+
problems.append(f"package.json files 白名单缺 {notes}(npm 包会缺发布说明)")
|
|
180
|
+
for path in sorted((root / "docs").glob("RELEASE_NOTES_v*.md")):
|
|
181
|
+
rel = f"docs/{path.name}"
|
|
182
|
+
if rel not in files:
|
|
183
|
+
problems.append(f"package.json files 白名单缺 {rel}(盘上有、包里没有)")
|
|
184
|
+
|
|
185
|
+
return problems
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def main(argv: list[str] | None = None) -> int:
|
|
189
|
+
ap = argparse.ArgumentParser(description="发布一致性预检")
|
|
190
|
+
ap.add_argument("--root", default=str(Path(__file__).resolve().parent.parent),
|
|
191
|
+
help="检出根目录(默认本仓库)")
|
|
192
|
+
args = ap.parse_args(argv)
|
|
193
|
+
root = Path(args.root)
|
|
194
|
+
problems = check(root)
|
|
195
|
+
try:
|
|
196
|
+
ver = _pyproject_version(root) or "?"
|
|
197
|
+
except OSError:
|
|
198
|
+
ver = "?" # 非检出目录:check() 已记问题,这里只负责别在报错路径上再炸
|
|
199
|
+
if problems:
|
|
200
|
+
print(f"release_check: v{ver} 不一致,{len(problems)} 项待修:", file=sys.stderr)
|
|
201
|
+
for p in problems:
|
|
202
|
+
print(f" !! {p}", file=sys.stderr)
|
|
203
|
+
return 1
|
|
204
|
+
print(f"release_check: v{ver} 一致(11 处机器声明 + 五语 README + 发布说明与白名单)")
|
|
205
|
+
return 0
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
if __name__ == "__main__":
|
|
209
|
+
sys.exit(main())
|
package/scripts/retry_policy.py
CHANGED
|
@@ -18,6 +18,7 @@ from __future__ import annotations
|
|
|
18
18
|
from typing import Any
|
|
19
19
|
|
|
20
20
|
from cache_guard import _QUOTA_ERROR_KEYWORDS
|
|
21
|
+
from engine_failure import NOTE_STATUS as _NOTE_STATUS
|
|
21
22
|
|
|
22
23
|
# 拦截页特征词(唯一来源):error 文本里出现即判 blocked。HTML 引擎的反爬
|
|
23
24
|
# 命中没有 error 文本(静默空结果),走 engines_base 的归因寄存器;
|
|
@@ -34,6 +35,17 @@ _BLOCKED_ERROR_KEYWORDS = (
|
|
|
34
35
|
# 结束、bot-wall 短退避,只有 transient 才重试一次)。
|
|
35
36
|
NON_RETRYABLE_STATUS = frozenset({"quota-exhausted", "auth-failed", "blocked"})
|
|
36
37
|
|
|
38
|
+
# 归因寄存器(engines_base.note_failure)的类别 → 是否确定性失败。
|
|
39
|
+
# 与上面的状态表同义,只是入口不同:HTML 抓取类引擎失败时往往返回空列表,
|
|
40
|
+
# 错误文本只写进归因寄存器,`classify_error_status` 看不到。2026-10-26 实测:
|
|
41
|
+
# octen 余额不足返回 [],调度层把它当「空结果可重试」,跑满 3 次(1934ms);
|
|
42
|
+
# local_bing 被反爬时同样重试。归因类别是同一事实的另一个出口,判据必须一致。
|
|
43
|
+
# 从 NOTE_STATUS(唯一映射表)派生,不另抄一份类别名单:rate_limited 映射到
|
|
44
|
+
# 非 NON_RETRYABLE_STATUS 的 "rate-limited",自动保持「限流可重试」。
|
|
45
|
+
_DETERMINISTIC_NOTE_CATEGORIES = frozenset(
|
|
46
|
+
cat for cat, status in _NOTE_STATUS.items()
|
|
47
|
+
if status in NON_RETRYABLE_STATUS)
|
|
48
|
+
|
|
37
49
|
|
|
38
50
|
def classify_error_status(message: Any) -> str:
|
|
39
51
|
"""错误文本 → 失败类别。**重试判据与归因判据的共同定义点**。
|
|
@@ -55,12 +67,21 @@ def classify_error_status(message: Any) -> str:
|
|
|
55
67
|
return "error"
|
|
56
68
|
|
|
57
69
|
|
|
58
|
-
def is_retryable_failure(res: list[Any] | None
|
|
70
|
+
def is_retryable_failure(res: list[Any] | None,
|
|
71
|
+
failure_note: dict[str, Any] | None = None) -> bool:
|
|
59
72
|
"""这组结果值不值得再试一次(纯函数,门禁可直接打到)。
|
|
60
73
|
|
|
61
74
|
判据取自 `classify_error_status`,与归因同源。空结果与无错误条目返回
|
|
62
75
|
True——沿用既有「重试一次」语义,本次只收紧确定性失败这一类。
|
|
76
|
+
|
|
77
|
+
`failure_note` 是归因寄存器的只读快照(engines_base.peek_failure_note):
|
|
78
|
+
抓取类引擎失败时返回空列表,错误只落在寄存器里,只查 `res` 会把配额耗尽
|
|
79
|
+
当空结果重试。两个入口共用同一张确定性类别表,避免「重试按一套判据、
|
|
80
|
+
熔断按另一套判据」。
|
|
63
81
|
"""
|
|
82
|
+
note_category = str((failure_note or {}).get("category") or "")
|
|
83
|
+
if note_category in _DETERMINISTIC_NOTE_CATEGORIES:
|
|
84
|
+
return False
|
|
64
85
|
for r in res or []:
|
|
65
86
|
if isinstance(r, dict) and "error" in r:
|
|
66
87
|
return classify_error_status(r.get("error")) not in NON_RETRYABLE_STATUS
|
package/scripts/robots_guard.py
CHANGED
|
@@ -241,6 +241,32 @@ def robots_blocked(url: str, timeout: float = 5.0) -> bool:
|
|
|
241
241
|
return False # 解析异常 → 放行
|
|
242
242
|
|
|
243
243
|
|
|
244
|
+
def crawl_delay(url: str, timeout: float = 5.0) -> float | None:
|
|
245
|
+
"""robots.txt 为该站声明的 Crawl-delay(秒);没有声明或取不到返回 None。
|
|
246
|
+
|
|
247
|
+
只取通配 UA 的声明:本技能 UA 轮换,具体 UA 的 delay 会漏掉 `User-agent: *`。
|
|
248
|
+
与 robots_blocked 共用同一个解析器缓存,不会为此多抓一次 robots.txt。
|
|
249
|
+
"""
|
|
250
|
+
if not _robots_enabled():
|
|
251
|
+
return None
|
|
252
|
+
scheme, host = _domain_key(url)
|
|
253
|
+
if not host:
|
|
254
|
+
return None
|
|
255
|
+
rp = _get_parser(scheme, host, timeout)
|
|
256
|
+
if rp is None:
|
|
257
|
+
return None
|
|
258
|
+
try:
|
|
259
|
+
value = rp.crawl_delay("*")
|
|
260
|
+
except Exception:
|
|
261
|
+
return None
|
|
262
|
+
if value is None:
|
|
263
|
+
return None
|
|
264
|
+
try:
|
|
265
|
+
return float(value)
|
|
266
|
+
except (TypeError, ValueError):
|
|
267
|
+
return None
|
|
268
|
+
|
|
269
|
+
|
|
244
270
|
# ─── 测试辅助 ────────────────────────────────────────────────────────────────
|
|
245
271
|
|
|
246
272
|
def clear_cache() -> None:
|
package/scripts/route.py
CHANGED
|
@@ -132,6 +132,7 @@ from paid_policy import insert_hedge
|
|
|
132
132
|
from route_combo import ( # noqa: E402
|
|
133
133
|
_expand_local_search,
|
|
134
134
|
_general_fallback,
|
|
135
|
+
general_kwargs,
|
|
135
136
|
_filter_breaker_blocked,
|
|
136
137
|
_maybe_add_geo_engine,
|
|
137
138
|
_apply_intent_parallelism,
|
|
@@ -425,9 +426,8 @@ def _route_by_domain(ctx: _RouteCtx, domain: dict[str, Any], secondary: list[dic
|
|
|
425
426
|
engines_combo = declared
|
|
426
427
|
if not engines_combo:
|
|
427
428
|
# 域内引擎全被过滤,回退(本地优先 + 通用免费源唯一来源)
|
|
428
|
-
engines_combo = _general_fallback(
|
|
429
|
-
|
|
430
|
-
engines_combo = sorted(enabled)[:2] if enabled else ["anysearch"]
|
|
429
|
+
engines_combo = _general_fallback(
|
|
430
|
+
enabled, **general_kwargs(features, mode, depth, context))
|
|
431
431
|
# 扩展 local_search → 子引擎
|
|
432
432
|
engines_combo = _expand_local_search(engines_combo, features)
|
|
433
433
|
|
|
@@ -599,7 +599,9 @@ def _route_by_domain(ctx: _RouteCtx, domain: dict[str, Any], secondary: list[dic
|
|
|
599
599
|
# 双引擎默认串行,利于 early-stop(答案域)
|
|
600
600
|
parallel = parallel and len(engines_combo) > 2
|
|
601
601
|
|
|
602
|
-
engines_combo = insert_hedge(
|
|
602
|
+
engines_combo = insert_hedge(
|
|
603
|
+
engines_combo, domain.get("name", ""), mode, enabled,
|
|
604
|
+
lang=str((features or {}).get("primary_lang") or ""))
|
|
603
605
|
|
|
604
606
|
return _done(
|
|
605
607
|
engine=engines_combo[0],
|
|
@@ -650,7 +652,9 @@ def _route_by_tfidf(ctx: _RouteCtx) -> dict[str, Any]:
|
|
|
650
652
|
_done = ctx.done
|
|
651
653
|
domain = None # 能走到这里说明没有域命中(含兜底域)
|
|
652
654
|
# 弱证据推荐只作辅源跟跑、通用保底领队;强证据维持推荐领队(route_combo)
|
|
653
|
-
engines_combo = tfidf_lead_combo(
|
|
655
|
+
engines_combo = tfidf_lead_combo(
|
|
656
|
+
tfidf_best, tfidf_best_score, enabled,
|
|
657
|
+
**general_kwargs(features, mode, depth, context))
|
|
654
658
|
# 🔑 展开 local_search → 子引擎
|
|
655
659
|
engines_combo = _expand_local_search(engines_combo, features)
|
|
656
660
|
# 🔑 为中文/学术查询追加本地引擎
|
|
@@ -724,9 +728,8 @@ def _route_by_fallback(ctx: _RouteCtx) -> dict[str, Any]:
|
|
|
724
728
|
tfidf_scores = ctx.tfidf_scores
|
|
725
729
|
_done = ctx.done
|
|
726
730
|
# 保底:免费通用引擎(零分 TF-IDF 也走这里)——本地优先 + 通用免费源唯一来源
|
|
727
|
-
fallback_combo = _general_fallback(
|
|
728
|
-
|
|
729
|
-
fallback_combo = sorted(enabled)[:2] if enabled else ["anysearch"]
|
|
731
|
+
fallback_combo = _general_fallback(
|
|
732
|
+
enabled, **general_kwargs(features, mode, depth, context))
|
|
730
733
|
# 日/韩主查询:优先 anysearch(多语言源对日/韩结果语言匹配更好),
|
|
731
734
|
# 再并语言专用本地引擎;避免旧逻辑只锁 local_bing(zh 参数)返回中文站。
|
|
732
735
|
# 注:byted 经实测对 ja/ko 也可,但其被 test_multilingual 定义为中文引擎,
|
package/scripts/route_cache.py
CHANGED
|
@@ -111,6 +111,12 @@ def _route_state_fingerprint() -> str:
|
|
|
111
111
|
_get_env = lambda k, d="": os.environ.get(k, d) # noqa: E731
|
|
112
112
|
parts.append("lead=" + (_get_env("ARGO_GENERAL_FALLBACK_LEAD") or ""))
|
|
113
113
|
parts.append("legacy=" + (_get_env("ARGO_GENERAL_FALLBACK_LEGACY") or ""))
|
|
114
|
+
# 静态臂同样是「改通用兜底链顺序」的开关(2026-10-26 新增)。不进指纹
|
|
115
|
+
# 会让「设了 STATIC=1 但缓存命中」读到动态排序,A/B 两臂变成同一臂。
|
|
116
|
+
parts.append("static=" + (_get_env("ARGO_GENERAL_FALLBACK_STATIC") or ""))
|
|
117
|
+
# 付费对冲位置同样改变 combo:常驻第二位 vs 第三位(免费源先跑)。
|
|
118
|
+
# 不进指纹会让 A/B 两臂在缓存命中时读到同一组合。
|
|
119
|
+
parts.append("hedge_defer=" + (_get_env("ARGO_PAID_HEDGE_DEFER") or ""))
|
|
114
120
|
# 付费对冲开关与月度预算同样改变 combo;不纳入指纹会让开关或预算变更在缓存命中时静默不生效。
|
|
115
121
|
parts.append("paid=" + (_get_env("ARGO_PAID_SEARCH") or ""))
|
|
116
122
|
try:
|