argo-search 2.14.1 → 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.
- package/AGENTS.md +8 -6
- package/README.es.md +54 -832
- package/README.ja.md +53 -833
- package/README.ko.md +53 -831
- package/README.md +126 -769
- package/README.zh.md +124 -893
- package/SKILL.md +17 -18
- package/assets/readme/counts.json +1 -1
- package/assets/readme/hero.svg +23 -23
- package/backends/concept_vectors.bin +0 -0
- package/backends/domain_profiles.json +42 -0
- package/backends/engine_concept_vectors.json +1525 -1525
- package/backends/engine_registry.yaml +124 -28
- package/backends/quota_profiles.json +70 -0
- package/bin/argo +30 -17
- package/config.yaml +173 -33
- package/docs/ADDING_NEW_ENGINE.md +10 -0
- package/docs/ARGO_INTRO.md +1 -1
- package/docs/CHANGELOG.md +23 -0
- package/docs/ENGINE_CATALOG.md +97 -85
- package/docs/MCP_SETUP.md +1 -1
- package/docs/RELEASE_NOTES_v2.14.1.md +4 -4
- package/docs/RELEASE_NOTES_v2.15.0.md +50 -0
- package/docs/RELEASING.md +1 -1
- package/engines/specs/ai_labs.yaml +89 -0
- package/engines/specs/bilibili_hot.yaml +11 -1
- package/engines/specs/brave.yaml +3 -3
- package/engines/specs/cisa_alerts.yaml +40 -0
- package/engines/specs/cn_ai_news.yaml +10 -8
- package/engines/specs/digup.yaml +11 -6
- package/engines/specs/douyin_hot.yaml +11 -1
- package/engines/specs/dw_news.yaml +4 -2
- package/engines/specs/eng_blogs.yaml +63 -0
- package/engines/specs/europeana.yaml +3 -4
- package/engines/specs/felo.yaml +3 -3
- package/engines/specs/firecrawl.yaml +3 -0
- package/engines/specs/fourget.yaml +5 -2
- package/engines/specs/france24.yaml +6 -4
- package/engines/specs/fxtwitter.yaml +29 -6
- package/engines/specs/grepapp_mcp.yaml +62 -0
- package/engines/specs/guardian_rss.yaml +6 -4
- package/engines/specs/itotii.yaml +13 -1
- package/engines/specs/lobsters.yaml +41 -0
- package/engines/specs/local_seek.yaml +6 -0
- package/engines/specs/open_meteo.yaml +1 -1
- package/engines/specs/redskill.yaml +2 -0
- package/engines/specs/searxng.yaml +4 -2
- package/engines/specs/sec_edgar.yaml +8 -3
- package/engines/specs/tinyfish.yaml +2 -0
- package/engines/specs/tinyfish_news.yaml +2 -0
- package/engines/specs/tinyfish_paper.yaml +2 -0
- package/engines/specs/toutiao_hot.yaml +11 -1
- package/engines/specs/train.yaml +3 -0
- package/engines/specs/twitter.yaml +4 -0
- package/engines/specs/unpaywall.yaml +6 -0
- package/engines/specs/vam.yaml +17 -3
- package/engines/specs/weibo_hot.yaml +11 -1
- package/engines/specs/wolframalpha.yaml +3 -3
- package/engines/specs/xiaohongshu.yaml +2 -0
- package/engines/specs/zhihu.yaml +3 -18
- package/engines/specs/zhihu_kb.yaml +18 -0
- package/engines/specs/zhihu_questions.yaml +19 -0
- package/package.json +3 -2
- package/packages/dsh-plugin/README.md +9 -14
- package/packages/dsh-plugin/dsh/client.js +467 -1024
- package/packages/dsh-plugin/dsh/diagnostics.js +71 -20
- package/packages/dsh-plugin/dsh/runner.js +2 -0
- package/packages/dsh-plugin/package.json +8 -3
- package/packages/dsh-plugin/scripts/sync-local.mjs +87 -0
- package/packages/dsh-plugin/scripts/sync-local.sh +13 -1
- package/packages/dsh-plugin/test/diagnostics.test.js +38 -1
- package/packages/dsh-plugin/test/size-gate.test.js +2 -9
- package/scripts/adaptive.py +7 -1
- package/scripts/archive_run.py +112 -53
- package/scripts/argo_paths.py +40 -3
- package/scripts/badcase_ledger.py +108 -9
- package/scripts/build_concept_table.py +112 -55
- package/scripts/cache.py +5 -1
- package/scripts/caliber_isolation.py +60 -23
- package/scripts/circuit_breaker.py +56 -8
- package/scripts/cli_io.py +20 -2
- package/scripts/config_cache.py +31 -0
- package/scripts/daemon.py +146 -51
- package/scripts/dormant_ledger.py +23 -9
- package/scripts/engine_dispatch.py +3 -3
- package/scripts/engine_env.py +182 -1
- package/scripts/engine_families.py +50 -7
- package/scripts/engine_states.py +3 -50
- package/scripts/engine_validate.py +13 -45
- package/scripts/engines.py +15 -31
- package/scripts/engines_base.py +42 -58
- package/scripts/engines_builders.py +0 -15
- package/scripts/engines_builders_batch10.py +346 -100
- package/scripts/engines_builders_batch11.py +2 -75
- package/scripts/engines_builders_batch9.py +15 -24
- package/scripts/engines_builders_cn.py +0 -194
- package/scripts/engines_builders_feeds.py +55 -5
- package/scripts/engines_builders_intl.py +15 -115
- package/scripts/engines_builders_pixiv.py +2 -16
- package/scripts/engines_builders_search.py +7 -14
- package/scripts/engines_builders_tech.py +5 -14
- package/scripts/engines_builders_weather.py +236 -0
- package/scripts/engines_fields.py +91 -0
- package/scripts/engines_http.py +135 -0
- package/scripts/engines_mcp.py +383 -0
- package/scripts/engines_parsers.py +13 -369
- package/scripts/engines_schema_drift.py +260 -0
- package/scripts/evidence.py +13 -0
- package/scripts/evidence_loop.py +4 -3
- package/scripts/fetch_jsrun.py +15 -11
- package/scripts/fetch_v3.py +28 -28
- package/scripts/fulltext_store.py +42 -1
- package/scripts/fxtwitter_api.py +8 -7
- package/scripts/gen_engine_catalog.py +2 -2
- package/scripts/general_pool.py +15 -4
- package/scripts/health_check.py +1 -1
- package/scripts/link_source.py +65 -24
- package/scripts/local_seek_adapter.py +57 -17
- package/scripts/mcp_handlers.py +53 -31
- package/scripts/mcp_handlers_surface.py +6 -18
- package/scripts/mcp_transport.py +1 -1
- package/scripts/min_version_scan.py +7 -3
- package/scripts/network_aware.py +7 -13
- package/scripts/pre-commit +45 -43
- package/scripts/query_understanding.py +30 -6
- package/scripts/quota.py +6 -1
- package/scripts/rank_signals.py +9 -0
- package/scripts/recompute.py +15 -5
- package/scripts/recovery.py +21 -15
- package/scripts/release.py +14 -26
- package/scripts/release_check.py +5 -25
- package/scripts/replay_eval.py +2 -2
- package/scripts/research_cli.py +40 -0
- package/scripts/research_notes.py +368 -0
- package/scripts/route.py +32 -70
- package/scripts/route_audit.py +259 -0
- package/scripts/route_combo.py +10 -4
- package/scripts/route_domains.py +150 -23
- package/scripts/route_lang.py +20 -7
- package/scripts/route_log.py +26 -9
- package/scripts/route_policy.py +85 -6
- package/scripts/route_telemetry_export.py +199 -0
- package/scripts/rrf_classic.py +5 -22
- package/scripts/search.py +2 -1
- package/scripts/search_attribution.py +33 -10
- package/scripts/search_entry.py +5 -1
- package/scripts/search_output.py +5 -4
- package/scripts/search_pipeline.py +12 -0
- package/scripts/search_rank.py +21 -11
- package/scripts/semantic_evidence.py +375 -168
- package/scripts/settings_page.py +3 -3
- package/scripts/social_engines/xiaohongshu_engine.py +2 -1
- package/scripts/social_engines/zhihu_engine.py +251 -43
- package/scripts/sogou_weixin_browser.py +5 -6
- package/scripts/source_audit.py +2 -2
- package/scripts/source_ledger.py +2 -15
- package/scripts/source_selection.py +45 -20
- package/scripts/straggler_policy.py +1 -2
- package/scripts/sync_backends.py +17 -0
- package/scripts/tfidf_router.py +23 -11
- package/scripts/time_utils.py +54 -1
- package/scripts/train.py +68 -2
- package/scripts/usage_log.py +26 -1
- package/sub-skills/argo-wide-research/SKILL.md +68 -0
- package/sub-skills/ego-search/SKILL.md +1 -1
- package/sub-skills/local-seek/scripts/seek_fts.py +58 -3
- package/scripts/caliber_dedupe.py +0 -66
- package/scripts/engines_builders_batch16.py +0 -13
- package/scripts/health_probe.py +0 -253
- package/scripts/social_engines/twitter_engine.py +0 -514
- package/scripts/sync_installs.py +0 -29
package/scripts/settings_page.py
CHANGED
|
@@ -452,10 +452,10 @@ def _run_list() -> int:
|
|
|
452
452
|
|
|
453
453
|
|
|
454
454
|
def _read_secret(prompt: str) -> str:
|
|
455
|
-
"""值只从 stdin 进来:tty 用 getpass
|
|
455
|
+
"""值只从 stdin 进来:tty 用 getpass 不回显,管道或内存流直接读一行。
|
|
456
456
|
值不进 argv——进程列表与 shell history 都不会留痕。"""
|
|
457
|
-
from cli_io import stdin_is_piped
|
|
458
|
-
if stdin_is_piped():
|
|
457
|
+
from cli_io import stdin_is_memory_stream, stdin_is_piped
|
|
458
|
+
if stdin_is_piped() or stdin_is_memory_stream():
|
|
459
459
|
return sys.stdin.readline().rstrip("\r\n").strip()
|
|
460
460
|
import getpass
|
|
461
461
|
return getpass.getpass(prompt).strip()
|
|
@@ -35,7 +35,8 @@ def _child_env() -> dict:
|
|
|
35
35
|
② 宿主注入 NO_PROXY=...,[::1] 时 xhs 内部 httpx 抛
|
|
36
36
|
InvalidURL: Invalid port ':1]' → 从 NO_PROXY/no_proxy 里剔掉 [::1]。
|
|
37
37
|
"""
|
|
38
|
-
|
|
38
|
+
from engine_env import build_child_env
|
|
39
|
+
env = build_child_env("xiaohongshu", {"allowed_env": ["ARGO_XHS_TIMEOUT"]})
|
|
39
40
|
env.setdefault("PYTHONUTF8", "1")
|
|
40
41
|
env.setdefault("PYTHONIOENCODING", "utf-8")
|
|
41
42
|
for key in ("NO_PROXY", "no_proxy"):
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
from __future__ import annotations
|
|
10
10
|
|
|
11
11
|
import json
|
|
12
|
+
import math
|
|
12
13
|
import os
|
|
14
|
+
import re
|
|
13
15
|
import time
|
|
14
16
|
import urllib.error
|
|
15
17
|
import urllib.parse
|
|
@@ -22,6 +24,142 @@ _sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
22
24
|
from net_proxy import http_get # noqa: E402
|
|
23
25
|
|
|
24
26
|
ZHIHU_API = "https://developer.zhihu.com/api/v1/content/zhihu_search"
|
|
27
|
+
ZHIHU_QUESTION_ANSWERS_API = "https://developer.zhihu.com/api/v1/content/question_answers"
|
|
28
|
+
_ZHIHU_SEARCH_COUNT_MAX = 10 # 官方 zhihu_search 上限 10
|
|
29
|
+
_ZHIHU_CLOCK_HINT_RE = re.compile(r"timestamp|时间戳|签名|时钟|clock", re.I)
|
|
30
|
+
_ZHIHU_CLOCK_HINT = "本机时钟可能偏差导致签名过期:先校准系统时间再重试,不必反复换密钥"
|
|
31
|
+
_HTML_TAG_RE = re.compile(r"<[^>]+>")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def parse_authority_level(raw: Any) -> int | None:
|
|
35
|
+
"""将上游 AuthorityLevel('1'..'4')解析为 0..4 整数,无效或空串返回 None。"""
|
|
36
|
+
if raw is None or isinstance(raw, bool):
|
|
37
|
+
return None
|
|
38
|
+
text = str(raw).strip()
|
|
39
|
+
if not text:
|
|
40
|
+
return None
|
|
41
|
+
try:
|
|
42
|
+
val = int(float(text))
|
|
43
|
+
except (TypeError, ValueError):
|
|
44
|
+
return None
|
|
45
|
+
return val if 0 <= val <= 4 else None
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def epoch_to_iso(ts: Any) -> str | None:
|
|
49
|
+
"""秒级 Unix 时间戳 → ISO 8601 UTC 字符串,不可解析返回 None。"""
|
|
50
|
+
if ts is None or isinstance(ts, bool):
|
|
51
|
+
return None
|
|
52
|
+
try:
|
|
53
|
+
val = float(ts)
|
|
54
|
+
except (TypeError, ValueError):
|
|
55
|
+
return None
|
|
56
|
+
if val <= 0:
|
|
57
|
+
return None
|
|
58
|
+
try:
|
|
59
|
+
return time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(val))
|
|
60
|
+
except (TypeError, ValueError, OSError):
|
|
61
|
+
return None
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def clean_zhihu_title(title: Any) -> str:
|
|
65
|
+
"""剥离知乎 API 标题尾部的 ' - 知乎'。"""
|
|
66
|
+
s = str(title or "").strip()
|
|
67
|
+
if s.endswith(" - 知乎"):
|
|
68
|
+
s = s[: -len(" - 知乎")].rstrip()
|
|
69
|
+
return s
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def strip_html_tags(text: Any) -> str:
|
|
73
|
+
"""去除 <em> 等高亮标签并折叠空白。"""
|
|
74
|
+
cleaned = _HTML_TAG_RE.sub("", str(text or ""))
|
|
75
|
+
return re.sub(r"\s+", " ", cleaned).strip()
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def extract_comment_snippets(raw_list: Any, limit: int = 2) -> list[str]:
|
|
79
|
+
"""提取 CommentInfoList 中的精选短评内容。"""
|
|
80
|
+
if not isinstance(raw_list, list):
|
|
81
|
+
return []
|
|
82
|
+
out: list[str] = []
|
|
83
|
+
for entry in raw_list:
|
|
84
|
+
if isinstance(entry, dict):
|
|
85
|
+
c = strip_html_tags(entry.get("Content") or "")
|
|
86
|
+
if c:
|
|
87
|
+
out.append(c[:160])
|
|
88
|
+
if len(out) >= limit:
|
|
89
|
+
break
|
|
90
|
+
return out
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def zhihu_headers(secret: str) -> dict[str, str]:
|
|
94
|
+
"""构造知乎开放平台通用鉴权请求头。"""
|
|
95
|
+
return {
|
|
96
|
+
"Authorization": f"Bearer {secret}",
|
|
97
|
+
"Content-Type": "application/json",
|
|
98
|
+
"X-Request-Timestamp": str(int(time.time())),
|
|
99
|
+
"User-Agent": "argo-search/2.6 (unified-search@local)",
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def zhihu_error_item(source: str, code: Any, message: Any) -> dict[str, Any]:
|
|
104
|
+
"""非成功响应的统一 error item:保留 code/message,时钟类附加校时提示。"""
|
|
105
|
+
text = f"{source} Code={code} {str(message or '')[:100]}".strip()
|
|
106
|
+
if _ZHIHU_CLOCK_HINT_RE.search(str(message or "")):
|
|
107
|
+
text = f"{text};hint: {_ZHIHU_CLOCK_HINT}"
|
|
108
|
+
return {"error": text, "source": source}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def fetch_question_answers(
|
|
112
|
+
question_url: str,
|
|
113
|
+
limit: int = 3,
|
|
114
|
+
timeout: float = 2.5,
|
|
115
|
+
*,
|
|
116
|
+
_secret_override: str | None = None,
|
|
117
|
+
) -> list[dict[str, Any]]:
|
|
118
|
+
"""获取知乎问题下的精选回答摘要(官方 question_answers 端点)。
|
|
119
|
+
|
|
120
|
+
返回项含 token、url、summary、content_type。网络异常或配额限制时降级返回空列表,不阻断主流程。
|
|
121
|
+
"""
|
|
122
|
+
if not question_url or not question_url.strip():
|
|
123
|
+
return []
|
|
124
|
+
secret = _secret_override if _secret_override is not None else _secret()
|
|
125
|
+
if not secret:
|
|
126
|
+
return []
|
|
127
|
+
|
|
128
|
+
# 规范化问题 URL:剥离多余路径和查询参数
|
|
129
|
+
m = re.search(r"(https?://(?:www\.)?zhihu\.com/question/\d+)", question_url.strip())
|
|
130
|
+
clean_url = m.group(1) if m else question_url.strip()
|
|
131
|
+
|
|
132
|
+
params = urllib.parse.urlencode({
|
|
133
|
+
"QuestionUrl": clean_url,
|
|
134
|
+
"Limit": str(max(1, min(int(limit), 50))),
|
|
135
|
+
"Offset": "0",
|
|
136
|
+
})
|
|
137
|
+
url = f"{ZHIHU_QUESTION_ANSWERS_API}?{params}"
|
|
138
|
+
headers = zhihu_headers(secret)
|
|
139
|
+
try:
|
|
140
|
+
body, _ = http_get(url, headers, timeout=timeout)
|
|
141
|
+
data = json.loads(body.decode("utf-8", "replace"))
|
|
142
|
+
if data.get("Code") in (0, None):
|
|
143
|
+
items = (data.get("Data") or {}).get("Items") or []
|
|
144
|
+
answers = []
|
|
145
|
+
for item in items:
|
|
146
|
+
if not isinstance(item, dict):
|
|
147
|
+
continue
|
|
148
|
+
summary = strip_html_tags(item.get("Summary") or "")
|
|
149
|
+
ans_url = item.get("Url") or ""
|
|
150
|
+
token = str(item.get("ContentToken") or "")
|
|
151
|
+
ctype = str(item.get("ContentType") or "answer").lower()
|
|
152
|
+
if summary or ans_url:
|
|
153
|
+
answers.append({
|
|
154
|
+
"token": token,
|
|
155
|
+
"url": ans_url,
|
|
156
|
+
"summary": summary,
|
|
157
|
+
"content_type": ctype,
|
|
158
|
+
})
|
|
159
|
+
return answers
|
|
160
|
+
except (OSError, ValueError, KeyError, TypeError) as exc:
|
|
161
|
+
_ = exc # 降级返回空列表,不阻断搜索主流程
|
|
162
|
+
return []
|
|
25
163
|
|
|
26
164
|
|
|
27
165
|
def _secret() -> str:
|
|
@@ -34,28 +172,31 @@ def _secret() -> str:
|
|
|
34
172
|
return os.environ.get("ZHIHU_ACCESS_SECRET") or os.environ.get("ARGO_ZHIHU_ACCESS_SECRET", "")
|
|
35
173
|
|
|
36
174
|
|
|
37
|
-
def search(
|
|
175
|
+
def search(
|
|
176
|
+
query: str,
|
|
177
|
+
n: int = 5,
|
|
178
|
+
expand_questions: bool = True,
|
|
179
|
+
*,
|
|
180
|
+
_secret_override: str | None = None,
|
|
181
|
+
_timeout: float = 10.0,
|
|
182
|
+
) -> list[dict[str, Any]]:
|
|
38
183
|
"""通过知乎开放平台 zhihu_search 搜索站内内容。"""
|
|
39
184
|
if not query or not query.strip():
|
|
40
185
|
return []
|
|
41
|
-
secret = _secret()
|
|
186
|
+
secret = _secret_override if _secret_override is not None else _secret()
|
|
42
187
|
if not secret:
|
|
43
188
|
return []
|
|
44
189
|
|
|
190
|
+
# 官方 zhihu_search Count 最大为 10(超出会被服务端截断,也不接受 SearchDB)
|
|
191
|
+
fetch_count = max(1, min(max(int(n) * 2, int(n)), _ZHIHU_SEARCH_COUNT_MAX))
|
|
45
192
|
params = urllib.parse.urlencode({
|
|
46
193
|
"Query": query.strip(),
|
|
47
|
-
"Count": str(
|
|
48
|
-
"SearchDB": "zhihu",
|
|
194
|
+
"Count": str(fetch_count),
|
|
49
195
|
})
|
|
50
196
|
url = f"{ZHIHU_API}?{params}"
|
|
51
|
-
headers =
|
|
52
|
-
"Authorization": f"Bearer {secret}",
|
|
53
|
-
"Content-Type": "application/json",
|
|
54
|
-
"X-Request-Timestamp": str(int(time.time())),
|
|
55
|
-
"User-Agent": "argo-search/2.6 (unified-search@local)",
|
|
56
|
-
}
|
|
197
|
+
headers = zhihu_headers(secret)
|
|
57
198
|
try:
|
|
58
|
-
body, _ = http_get(url, headers, timeout=
|
|
199
|
+
body, _ = http_get(url, headers, timeout=_timeout)
|
|
59
200
|
data = json.loads(body.decode("utf-8", "replace"))
|
|
60
201
|
except urllib.error.HTTPError as e:
|
|
61
202
|
# 密钥无效/过期(401/403)等必须暴露为 auth-failed,而不是静默
|
|
@@ -65,63 +206,129 @@ def search(query: str, n: int = 5) -> list[dict[str, Any]]:
|
|
|
65
206
|
return [{"error": f"zhihu API {type(e).__name__}: {e}", "source": "zhihu"}]
|
|
66
207
|
|
|
67
208
|
if data.get("Code") not in (0, None):
|
|
68
|
-
return [
|
|
69
|
-
f"{str(data.get('Message') or '')[:100]}",
|
|
70
|
-
"source": "zhihu"}]
|
|
209
|
+
return [zhihu_error_item("zhihu", data.get("Code"), data.get("Message"))]
|
|
71
210
|
|
|
72
|
-
|
|
211
|
+
candidates: list[dict[str, Any]] = []
|
|
73
212
|
items = (data.get("Data") or {}).get("Items") or []
|
|
74
|
-
|
|
213
|
+
expanded_count = 0
|
|
214
|
+
max_expand = 2 # 一次搜索最多下钻展开前 2 个纯问题,平衡配额与延迟
|
|
215
|
+
|
|
216
|
+
for rank, item in enumerate(items):
|
|
75
217
|
if not isinstance(item, dict):
|
|
76
218
|
continue
|
|
77
|
-
title = (item.get("Title")
|
|
78
|
-
# API 标题统一带「 - 知乎」尾巴:截断前剥掉(先剥再切,尾巴不占正文)
|
|
79
|
-
if title.endswith(" - 知乎"):
|
|
80
|
-
title = title[: -len(" - 知乎")].rstrip()
|
|
219
|
+
title = clean_zhihu_title(item.get("Title"))
|
|
81
220
|
url_ = item.get("Url") or ""
|
|
82
|
-
|
|
221
|
+
raw_text = strip_html_tags(item.get("ContentText") or title)
|
|
222
|
+
snippet = raw_text[:500]
|
|
83
223
|
if not title and not url_:
|
|
84
224
|
continue
|
|
85
225
|
content_id = str(item.get("ContentID") or "")
|
|
86
226
|
author = item.get("AuthorName") or ""
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
227
|
+
content_type = (item.get("ContentType") or "answer").lower()
|
|
228
|
+
try:
|
|
229
|
+
likes = int(item.get("VoteUpCount") or 0)
|
|
230
|
+
except (ValueError, TypeError):
|
|
231
|
+
likes = 0
|
|
232
|
+
try:
|
|
233
|
+
comments = int(item.get("CommentCount") or 0)
|
|
234
|
+
except (ValueError, TypeError):
|
|
235
|
+
comments = 0
|
|
236
|
+
published = epoch_to_iso(item.get("EditTime"))
|
|
237
|
+
upstream_auth = parse_authority_level(item.get("AuthorityLevel"))
|
|
238
|
+
badge_text = str(item.get("AuthorBadgeText") or "").strip()
|
|
239
|
+
top_comments = extract_comment_snippets(item.get("CommentInfoList"))
|
|
240
|
+
ranking_score = item.get("RankingScore")
|
|
241
|
+
|
|
242
|
+
# 识别纯问题:支持自动下钻抓取 Top 精选回答摘要(方案 B:Question Answers Expansion)
|
|
243
|
+
is_pure_question = (content_type == "question") or ("/question/" in url_ and "/answer/" not in url_)
|
|
244
|
+
expanded_answers: list[dict[str, Any]] = []
|
|
245
|
+
if is_pure_question and expand_questions and expanded_count < max_expand:
|
|
246
|
+
expanded_count += 1
|
|
247
|
+
expanded_answers = fetch_question_answers(url_, limit=3, _secret_override=secret)
|
|
248
|
+
if expanded_answers:
|
|
249
|
+
answer_summaries = [f"【回答 {i+1}】{a['summary']}" for i, a in enumerate(expanded_answers[:2]) if a.get("summary")]
|
|
250
|
+
if answer_summaries:
|
|
251
|
+
addon = " ".join(answer_summaries)
|
|
252
|
+
snippet = f"{snippet} | {addon}"[:500] if snippet else addon[:500]
|
|
91
253
|
|
|
92
|
-
|
|
254
|
+
# 结合上游相关性序位与社区点赞/评论/权威分做质量综合评分
|
|
255
|
+
base_relevance = max(1.0 - rank * 0.05, 0.2)
|
|
256
|
+
like_boost = min(0.3, math.log10(likes + 1) * 0.08)
|
|
257
|
+
comment_boost = min(0.1, math.log10(comments + 1) * 0.03)
|
|
258
|
+
expand_boost = 0.08 if expanded_answers else 0.0
|
|
259
|
+
auth_boost = (upstream_auth - 1) * 0.02 if upstream_auth and upstream_auth >= 2 else 0.0
|
|
260
|
+
quality_score = round(min(1.0, base_relevance * 0.7 + like_boost + comment_boost + expand_boost + auth_boost), 4)
|
|
261
|
+
|
|
262
|
+
social_meta: dict[str, Any] = {
|
|
263
|
+
"platform": "zhihu",
|
|
264
|
+
"content_type": content_type,
|
|
265
|
+
"id": content_id,
|
|
266
|
+
"author": author,
|
|
267
|
+
"likes": likes,
|
|
268
|
+
"upvotes": likes,
|
|
269
|
+
"comments": comments,
|
|
270
|
+
"provider": "zhihu_openapi",
|
|
271
|
+
"is_question": is_pure_question,
|
|
272
|
+
"has_expanded_answers": bool(expanded_answers),
|
|
273
|
+
}
|
|
274
|
+
if item.get("AuthorityLevel") not in (None, ""):
|
|
275
|
+
social_meta["authority_level"] = str(item.get("AuthorityLevel"))
|
|
276
|
+
if badge_text:
|
|
277
|
+
social_meta["author_badge_text"] = badge_text
|
|
278
|
+
if top_comments:
|
|
279
|
+
social_meta["top_comments"] = top_comments
|
|
280
|
+
if isinstance(ranking_score, (int, float)):
|
|
281
|
+
social_meta["ranking_score"] = round(float(ranking_score), 4)
|
|
282
|
+
if expanded_answers:
|
|
283
|
+
social_meta["answers"] = [
|
|
284
|
+
{"url": a["url"], "summary": a["summary"]} for a in expanded_answers
|
|
285
|
+
]
|
|
286
|
+
|
|
287
|
+
entry: dict[str, Any] = {
|
|
93
288
|
"title": title[:100] + ("..." if len(title) > 100 else ""),
|
|
94
289
|
"url": url_,
|
|
95
290
|
"snippet": snippet,
|
|
96
291
|
"source": "zhihu",
|
|
97
|
-
"score":
|
|
292
|
+
"score": quality_score,
|
|
98
293
|
"published_at": published,
|
|
99
|
-
"social_meta":
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
})
|
|
109
|
-
return results
|
|
294
|
+
"social_meta": social_meta,
|
|
295
|
+
}
|
|
296
|
+
if upstream_auth is not None:
|
|
297
|
+
entry["upstream_authority"] = upstream_auth
|
|
298
|
+
candidates.append(entry)
|
|
299
|
+
|
|
300
|
+
# 按综合得分降序微调,确保高赞高质量答案排在前面,并保留前 n 条
|
|
301
|
+
candidates.sort(key=lambda r: r["score"], reverse=True)
|
|
302
|
+
return candidates[:n]
|
|
110
303
|
|
|
111
304
|
|
|
112
305
|
def main():
|
|
113
306
|
import argparse
|
|
114
307
|
parser = argparse.ArgumentParser(description="Zhihu search engine (zhihu_openapi)")
|
|
115
|
-
parser.add_argument("action", nargs="?", default="search")
|
|
116
|
-
parser.add_argument("query", nargs="?")
|
|
308
|
+
parser.add_argument("action", nargs="?", default="search", help="search | answers")
|
|
309
|
+
parser.add_argument("query", nargs="?", help="Search query or question URL")
|
|
117
310
|
parser.add_argument("-n", type=int, default=5)
|
|
311
|
+
parser.add_argument("--no-expand", action="store_true", help="Disable question answers expansion")
|
|
118
312
|
parser.add_argument("--json", action="store_true")
|
|
119
313
|
args = parser.parse_args()
|
|
120
314
|
|
|
121
315
|
if not args.query:
|
|
122
316
|
print("[]")
|
|
123
317
|
return
|
|
124
|
-
|
|
318
|
+
|
|
319
|
+
if args.action in ("answers", "question_answers"):
|
|
320
|
+
answers = fetch_question_answers(args.query, limit=args.n)
|
|
321
|
+
if args.json:
|
|
322
|
+
print(json.dumps(answers, ensure_ascii=False))
|
|
323
|
+
else:
|
|
324
|
+
for i, a in enumerate(answers, 1):
|
|
325
|
+
print(f"### Answer {i}")
|
|
326
|
+
print(f"- URL: {a['url']}")
|
|
327
|
+
print(f"- {a['summary']}")
|
|
328
|
+
print()
|
|
329
|
+
return
|
|
330
|
+
|
|
331
|
+
results = search(args.query, args.n, expand_questions=not args.no_expand)
|
|
125
332
|
if args.json:
|
|
126
333
|
print(json.dumps(results, ensure_ascii=False))
|
|
127
334
|
else:
|
|
@@ -129,8 +336,9 @@ def main():
|
|
|
129
336
|
meta = r.get("social_meta") or {}
|
|
130
337
|
print(f"### {i}. {r['title']}")
|
|
131
338
|
print(f"- **URL**: {r['url']}")
|
|
132
|
-
print(f"- {r['snippet'][:
|
|
133
|
-
print(f"- likes={meta.get('likes')} comments={meta.get('comments')} @{meta.get('author', '')}"
|
|
339
|
+
print(f"- {r['snippet'][:250]}")
|
|
340
|
+
print(f"- likes={meta.get('likes')} comments={meta.get('comments')} @{meta.get('author', '')} "
|
|
341
|
+
f"[question={meta.get('is_question')} expanded={meta.get('has_expanded_answers')}]")
|
|
134
342
|
print()
|
|
135
343
|
|
|
136
344
|
|
|
@@ -32,7 +32,6 @@ task.finish()(ego-browser「默认关闭空间」之例外:结果必须留
|
|
|
32
32
|
from __future__ import annotations
|
|
33
33
|
|
|
34
34
|
import argparse
|
|
35
|
-
import fcntl
|
|
36
35
|
import json
|
|
37
36
|
import os
|
|
38
37
|
import re
|
|
@@ -40,6 +39,9 @@ import shutil
|
|
|
40
39
|
import subprocess
|
|
41
40
|
import sys
|
|
42
41
|
import tempfile
|
|
42
|
+
from pathlib import Path
|
|
43
|
+
|
|
44
|
+
from argo_paths import file_lock
|
|
43
45
|
import time
|
|
44
46
|
from datetime import datetime
|
|
45
47
|
from urllib.parse import quote
|
|
@@ -241,11 +243,8 @@ def main(argv: list | None = None) -> int:
|
|
|
241
243
|
file=sys.stderr)
|
|
242
244
|
return 1
|
|
243
245
|
|
|
244
|
-
# 文件锁串行化:并发调用会争抢同一浏览器页(goto
|
|
245
|
-
|
|
246
|
-
os.makedirs(os.path.dirname(lock_path) or ".", exist_ok=True)
|
|
247
|
-
with open(lock_path, "w", encoding="utf-8") as lock_f:
|
|
248
|
-
fcntl.flock(lock_f, fcntl.LOCK_EX)
|
|
246
|
+
# 文件锁串行化:并发调用会争抢同一浏览器页(goto 竞态)与节流窗口(复用 argo_paths 跨平台锁)
|
|
247
|
+
with file_lock(Path(state_path), timeout=30.0):
|
|
249
248
|
state = _load_state(state_path)
|
|
250
249
|
last_ts = float(state.get("last_ts") or 0)
|
|
251
250
|
wait = args.min_interval - (time.time() - last_ts)
|
package/scripts/source_audit.py
CHANGED
|
@@ -300,8 +300,8 @@ def render(report: dict, verbose: bool = False) -> str:
|
|
|
300
300
|
|
|
301
301
|
lines.append(" 运行 `argo doctor --fix` 自动执行停用与隔离;降级需人工判断。")
|
|
302
302
|
lines.append(" 对交付率异常的声明式源,可运行 `python3 scripts/engine_validate.py -e <id> --diagnose`"
|
|
303
|
-
" (或 `--fix`)
|
|
304
|
-
"
|
|
303
|
+
" (或 `--fix`) 探测结构漂移并输出建议补丁(只读预览);"
|
|
304
|
+
"确认无误后手动更新 `engines/specs/<id>.yaml`。")
|
|
305
305
|
return "\n".join(lines)
|
|
306
306
|
|
|
307
307
|
|
package/scripts/source_ledger.py
CHANGED
|
@@ -17,6 +17,8 @@ from datetime import datetime, timezone, timedelta
|
|
|
17
17
|
from typing import Any, Optional
|
|
18
18
|
from urllib.parse import urlparse
|
|
19
19
|
|
|
20
|
+
from evidence_tier import _extract_host # 主机名提取真源在 evidence_tier,本模块只复用
|
|
21
|
+
|
|
20
22
|
|
|
21
23
|
# ── 数据结构 ────────────────────────────────────────────────────────
|
|
22
24
|
|
|
@@ -208,21 +210,6 @@ def infer_access_status(url: str, fetch_success: bool = True, http_status: int =
|
|
|
208
210
|
return "unknown"
|
|
209
211
|
|
|
210
212
|
|
|
211
|
-
def _extract_host(url: str) -> str:
|
|
212
|
-
"""提取主机名"""
|
|
213
|
-
if not url:
|
|
214
|
-
return ""
|
|
215
|
-
try:
|
|
216
|
-
host = urlparse(url).netloc.lower()
|
|
217
|
-
if "@" in host:
|
|
218
|
-
host = host.rsplit("@", 1)[1]
|
|
219
|
-
if ":" in host:
|
|
220
|
-
host = host.split(":", 1)[0]
|
|
221
|
-
return host
|
|
222
|
-
except Exception:
|
|
223
|
-
return ""
|
|
224
|
-
|
|
225
|
-
|
|
226
213
|
def create_source_record(
|
|
227
214
|
url: str,
|
|
228
215
|
publisher: str = "",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
from __future__ import annotations
|
|
44
44
|
|
|
45
45
|
from typing import Callable
|
|
46
|
+
from except_sets import IO_BENIGN, SHAPE_BENIGN # 收窄词汇表(2026-11-13 裸吞收口)
|
|
46
47
|
|
|
47
48
|
# 先验 = 实测延迟 + 词面相关 + 稳定性的人工压缩(0–1)。只列通用候选;
|
|
48
49
|
# 未列出的源给 DEFAULT_PRIOR,不会凭名字占便宜。
|
|
@@ -130,13 +131,16 @@ def _coverage_of(engine: str) -> tuple[str, ...]:
|
|
|
130
131
|
|
|
131
132
|
|
|
132
133
|
def _lang_misfit(engine: str, lang: str) -> bool:
|
|
133
|
-
"""
|
|
134
|
-
pair = _LANG_PAIR.get(lang)
|
|
135
|
-
if not pair:
|
|
136
|
-
return False
|
|
137
|
-
own, other = pair
|
|
134
|
+
"""查询语言与源声明语言错配(覆盖中文/英文及明确非中文语种对中文专源错配)。"""
|
|
138
135
|
cov = {str(c).lower() for c in _coverage_of(engine)}
|
|
139
|
-
|
|
136
|
+
pair = _LANG_PAIR.get(lang)
|
|
137
|
+
if pair:
|
|
138
|
+
own, other = pair
|
|
139
|
+
return other in cov and own not in cov
|
|
140
|
+
if lang and lang not in ("zh", "mixed", "other"):
|
|
141
|
+
# 非中文语种查询避免把仅声明 chinese 的源当首选
|
|
142
|
+
return "chinese" in cov and "english" not in cov and "multilingual" not in cov
|
|
143
|
+
return False
|
|
140
144
|
|
|
141
145
|
|
|
142
146
|
# 非中英脚本(西里尔/阿拉伯/日韩…)不参与覆盖地板与语言门:那些语言下
|
|
@@ -147,29 +151,41 @@ _TIERED_LANGS = frozenset({"zh", "en", "mixed", "other", ""})
|
|
|
147
151
|
def _tier(engine: str, lang: str) -> int:
|
|
148
152
|
"""排序层级:0 合格(覆盖够 + 语言适配)/ 1 语言错配 / 2 交付太薄。"""
|
|
149
153
|
if lang not in _TIERED_LANGS:
|
|
150
|
-
return 0
|
|
154
|
+
return 1 if _lang_misfit(engine, lang) else 0
|
|
151
155
|
if GENERAL_COVERAGE.get(engine, COVERAGE_FLOOR) < COVERAGE_FLOOR:
|
|
152
156
|
return 2
|
|
153
157
|
return 1 if _lang_misfit(engine, lang) else 0
|
|
154
158
|
|
|
155
159
|
# 非中英查询的语言覆盖加成。先验表是在中英查询上测的;西里尔/阿拉伯/
|
|
156
|
-
#
|
|
157
|
-
#
|
|
158
|
-
# 不做这层加成,top-2 会全被 tavily/parallel 占掉,语言源被预算截断。
|
|
160
|
+
# 日韩及欧洲小语种查询下,多语言覆盖源(anysearch/local_bing 带动态 setlang)
|
|
161
|
+
# 比英文或中文单语快源更有召回价值。
|
|
159
162
|
_NON_LATIN_LANG_BOOST: dict[str, float] = {
|
|
160
163
|
"anysearch": 0.35,
|
|
161
164
|
"local_bing": 0.40,
|
|
162
165
|
}
|
|
163
166
|
_LATIN_OR_CN_LANGS = frozenset({"zh", "en", "mixed", "other", ""})
|
|
164
167
|
|
|
168
|
+
# 意图微调权重(零基兜底分化:同语言层级下,新闻偏时效多源,对比/事实偏结构摘要)
|
|
169
|
+
_INTENT_PRIOR_BOOST: dict[str, dict[str, float]] = {
|
|
170
|
+
"news": {"anysearch": 0.08, "local_bing": 0.04},
|
|
171
|
+
"compare": {"parallel_free": 0.06, "tavily_free": 0.04, "uapi": 0.04},
|
|
172
|
+
"definition": {"parallel_free": 0.06, "tavily_free": 0.04, "uapi": 0.04},
|
|
173
|
+
"fact": {"parallel_free": 0.06, "tavily_free": 0.04},
|
|
174
|
+
"social": {"anysearch": 0.05},
|
|
175
|
+
}
|
|
176
|
+
|
|
165
177
|
# 有 ≥3 条自适应样本时,先验与自适应分各占一半;否则先验做主。
|
|
166
178
|
_ADAPTIVE_BLEND_SAMPLES = 3
|
|
167
179
|
|
|
168
180
|
|
|
169
|
-
def _prior_for(engine: str, lang: str
|
|
181
|
+
def _prior_for(engine: str, lang: str,
|
|
182
|
+
intents: list[str] | tuple[str, ...] | None = None) -> float:
|
|
170
183
|
prior = GENERAL_PRIORS.get(engine, DEFAULT_PRIOR)
|
|
171
184
|
if lang not in _LATIN_OR_CN_LANGS:
|
|
172
185
|
prior += _NON_LATIN_LANG_BOOST.get(engine, 0.0)
|
|
186
|
+
if intents:
|
|
187
|
+
bonus = max((_INTENT_PRIOR_BOOST.get(it, {}).get(engine, 0.0) for it in intents), default=0.0)
|
|
188
|
+
prior += bonus
|
|
173
189
|
return prior
|
|
174
190
|
|
|
175
191
|
|
|
@@ -193,12 +209,14 @@ def _usable(candidates: list[str], *, mode: str) -> list[str]:
|
|
|
193
209
|
try:
|
|
194
210
|
exhausted = qm.remote_exhausted_marks()
|
|
195
211
|
out = [e for e in out if e not in exhausted]
|
|
196
|
-
except
|
|
212
|
+
except IO_BENIGN + SHAPE_BENIGN:
|
|
197
213
|
pass
|
|
198
214
|
if mode in ("fast", "budget"):
|
|
199
215
|
out = [e for e in out if qm.is_available(e, mode=mode)]
|
|
200
|
-
except Exception:
|
|
201
|
-
|
|
216
|
+
except Exception as e:
|
|
217
|
+
import logging
|
|
218
|
+
logging.getLogger("unified_search").debug(
|
|
219
|
+
f"quota 可用性过滤跳过(fail-open): {type(e).__name__}")
|
|
202
220
|
return out
|
|
203
221
|
|
|
204
222
|
|
|
@@ -226,14 +244,20 @@ def _paid_candidate_allowed(engine: str, mode: str) -> bool:
|
|
|
226
244
|
from engine_env import is_engine_allowed_by_env
|
|
227
245
|
if not is_engine_allowed_by_env(engine):
|
|
228
246
|
return False
|
|
229
|
-
except Exception:
|
|
230
|
-
|
|
247
|
+
except Exception as e:
|
|
248
|
+
import logging
|
|
249
|
+
logging.getLogger("unified_search").debug(
|
|
250
|
+
f"引擎 env 准入检查异常按禁止处理: {type(e).__name__}")
|
|
251
|
+
return False
|
|
231
252
|
try:
|
|
232
253
|
from engine_admission import is_blocked
|
|
233
254
|
if is_blocked(engine):
|
|
234
255
|
return False
|
|
235
|
-
except Exception:
|
|
236
|
-
|
|
256
|
+
except Exception as e:
|
|
257
|
+
import logging
|
|
258
|
+
logging.getLogger("unified_search").debug(
|
|
259
|
+
f"引擎准入 is_blocked 检查异常按禁止处理: {type(e).__name__}")
|
|
260
|
+
return False
|
|
237
261
|
try:
|
|
238
262
|
from quota import get_quota_manager
|
|
239
263
|
return not get_quota_manager().is_hard_down(engine)
|
|
@@ -259,9 +283,10 @@ def rank_general_candidates(
|
|
|
259
283
|
depth: str = "fast",
|
|
260
284
|
context: str = "search",
|
|
261
285
|
lang: str = "",
|
|
286
|
+
intents: list[str] | tuple[str, ...] | None = None,
|
|
262
287
|
score_fn: Callable[[str, str, str, str], tuple[float, int]] | None = None,
|
|
263
288
|
) -> list[str]:
|
|
264
|
-
"""按「先验 × 自适应 ×
|
|
289
|
+
"""按「先验 × 自适应 × 用途 × (语言/意图分化)」排序通用候选源。
|
|
265
290
|
|
|
266
291
|
`score_fn(engine, domain, lang, purpose) -> (score, samples)` 可注入,
|
|
267
292
|
测试用假学习器即可确定性断言,不依赖本机 adaptive.db 的时点数据。
|
|
@@ -281,7 +306,7 @@ def rank_general_candidates(
|
|
|
281
306
|
|
|
282
307
|
ranked: list[tuple[int, float, int, str]] = []
|
|
283
308
|
for idx, engine in enumerate(pool):
|
|
284
|
-
prior = _prior_for(engine, lang)
|
|
309
|
+
prior = _prior_for(engine, lang, intents=intents)
|
|
285
310
|
try:
|
|
286
311
|
adaptive_score, samples = score_fn(
|
|
287
312
|
engine, "general_search", lang, purpose)
|
|
@@ -8,8 +8,7 @@ search.py 是被 module size 门禁盯着的文件(1000 行硬限),本次
|
|
|
8
8
|
一处,调用侧只留一行接线。
|
|
9
9
|
|
|
10
10
|
默认关(ARGO_ADAPTIVE_TAIL=1 开启):理由是**本开关自己的**交错 A/B 未证实
|
|
11
|
-
收益——2026-10-16
|
|
12
|
-
docs-local/调度对拍_尾宽分层与并发_2026-10-16.md:墙钟有改善但统计不显著,
|
|
11
|
+
收益——2026-10-16 三轮对拍:墙钟有改善但统计不显著,
|
|
13
12
|
按「调度旋钮的收益必须由 A/B 证明后才转默认开」的规矩保持关闭。
|
|
14
13
|
别拿 ARGO_ADAPTIVE_GRACE 的现状作类比:那个 2026-10-19(c52b7d4)已转默认
|
|
15
14
|
开,两者的 A/B 结论不同,各自独立判断。
|
package/scripts/sync_backends.py
CHANGED
|
@@ -62,6 +62,15 @@ _KEYREFS_END = " // </generated:keyrefs>\n"
|
|
|
62
62
|
# 旧面板手写名单里与候选链规则不一致的 ref(候选链里确实有这个名字,运行时
|
|
63
63
|
# get_env 能读到):保留旧名,否则 DSH 凭证库里已存的 key 改名后面板显示未配置
|
|
64
64
|
DSH_LEGACY_REFS = {"ARGO_BYTED_API_KEY": "WEB_SEARCH_API_KEY"}
|
|
65
|
+
# 语义证据层(非引擎)凭证:Gemini Decision 1 首选通道与 TypeSafe JEV 备用
|
|
66
|
+
# 通道(semantic_evidence.py 三级阶梯的钥匙)。它们不是引擎、引擎声明派生不
|
|
67
|
+
# 到,这里显式补录,密钥页与 keyRefs 转发才不漏;ref 用裸名(凭证库存名习惯),
|
|
68
|
+
# argo 侧候选链(ARGO_GEMINI_API_KEY/GEMINI_API_KEY、ARGO_JEV_API_KEY/
|
|
69
|
+
# TYPESAFE_API_KEY)第二位即命中。
|
|
70
|
+
DSH_SEMANTIC_KEYS = [
|
|
71
|
+
{"ref": "GEMINI_API_KEY", "label": "语义证据·Gemini 决策", "en": "Semantic Evidence · Gemini Decision"},
|
|
72
|
+
{"ref": "TYPESAFE_API_KEY", "label": "语义证据·JEV(TypeSafe)", "en": "Semantic Evidence · JEV (TypeSafe)"},
|
|
73
|
+
]
|
|
65
74
|
DSH_COMMON_KEYS = ("DEEPSEEK_API_KEY", "ARGO_YUANBAO_API_KEY", "ARGO_TAVILY_API_KEY",
|
|
66
75
|
"ARGO_EXA_API_KEY", "ARGO_BOCHA_API_KEY", "ARGO_BRAVE_API_KEY",
|
|
67
76
|
"ARGO_TINYFISH_API_KEY")
|
|
@@ -78,6 +87,7 @@ DSH_EN_LABELS: dict[str, str] = {
|
|
|
78
87
|
"EASTMONEY_APIKEY": "Eastmoney Miaoxiang",
|
|
79
88
|
"FELO_API_KEY": "Felo AI Search",
|
|
80
89
|
"FIRECRAWL_API_KEY": "Firecrawl",
|
|
90
|
+
"FOURGET_URL": "4get",
|
|
81
91
|
"GITHUB_TOKEN": "GitHub",
|
|
82
92
|
"KEENABLE_API_KEY": "Keenable",
|
|
83
93
|
"METASO_API_KEY": "Metaso",
|
|
@@ -304,6 +314,13 @@ def derive_dsh_keys(engines: dict[str, dict[str, Any]]) -> list[dict[str, Any]]:
|
|
|
304
314
|
en = DSH_EN_LABELS.get(ref) or g["engines"][0].replace("_", " ").title()
|
|
305
315
|
out.append({"ref": ref, "common": primary in DSH_COMMON_KEYS,
|
|
306
316
|
"label": g["label"], "en": en, "engines": g["engines"]})
|
|
317
|
+
# 非引擎凭证补录(语义证据层):engines 留空,密钥页按「不覆盖引擎」渲染;
|
|
318
|
+
# 已与某引擎派生 ref 撞名时让位(known 去重),避免同 ref 两行。
|
|
319
|
+
known = {r["ref"] for r in out}
|
|
320
|
+
for row in DSH_SEMANTIC_KEYS:
|
|
321
|
+
if row["ref"] not in known:
|
|
322
|
+
out.append({"ref": row["ref"], "common": False, "label": row["label"],
|
|
323
|
+
"en": row["en"], "engines": []})
|
|
307
324
|
out.sort(key=lambda r: (not r["common"],
|
|
308
325
|
DSH_COMMON_KEYS.index(next(p for p in DSH_COMMON_KEYS
|
|
309
326
|
if p in (r["ref"], "ARGO_" + r["ref"])))
|