argo-search 2.10.0 → 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.
- package/README.en.md +24 -10
- package/README.es.md +23 -9
- package/README.ja.md +24 -10
- package/README.ko.md +24 -10
- package/README.md +24 -10
- package/SKILL.md +11 -10
- package/backends/engine_registry.yaml +2 -2
- package/backends/source_types_cn.json +9 -0
- package/config.yaml +23 -10
- package/docs/ENGINE_CATALOG.md +8 -8
- package/docs/RELEASE_NOTES_v2.10.1.md +57 -0
- package/engines/_template_http.yaml +2 -0
- package/engines/specs/ncpssd.yaml +3 -0
- package/engines/specs/sciverse.yaml +1 -0
- package/package.json +3 -2
- package/packages/dsh-plugin/package.json +1 -1
- package/scripts/ci_drift_gate.py +47 -24
- package/scripts/engine_dispatch.py +6 -8
- package/scripts/engine_status.py +12 -5
- package/scripts/engines.py +5 -0
- package/scripts/engines_base.py +31 -15
- package/scripts/engines_builders_data.py +10 -3
- package/scripts/evidence.py +26 -5
- package/scripts/local_seek.py +53 -11
- package/scripts/mcp_transport.py +1 -1
- package/scripts/release.py +398 -0
- package/scripts/route_domains.py +18 -2
- package/scripts/search.py +4 -2
- package/scripts/search_cli.py +22 -0
- package/scripts/search_output.py +14 -0
- package/scripts/search_pipeline.py +4 -2
- package/scripts/search_rank.py +3 -1
- package/scripts/serp_guard.py +11 -0
- package/scripts/url_canon.py +2 -1
- package/scripts/video_route.py +3 -3
- package/sub-skills/local-seek/scripts/seek.py +19 -4
- package/engines/specs/_cisa_kev.yaml +0 -54
- package/engines/specs/_osv.yaml +0 -63
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""release.py — 一条链发版:改号 → 校验 → 提交打标签 → 发 npm → 轮询核验。
|
|
3
|
+
|
|
4
|
+
## 为什么要它
|
|
5
|
+
|
|
6
|
+
版本号散在 11 处机器声明、五语 README 的徽标 / 散文 / 发布表,外加发布说明
|
|
7
|
+
与 npm files 白名单。v2.10.0 发版时手改了 26 个文件,v2.9.8 更漏过 README
|
|
8
|
+
「最近更新」条目——漏改往往等 npm 包发出去才发现。release_check.py 只能事后
|
|
9
|
+
报错,本脚本把「改」和「发」也收成确定性步骤。
|
|
10
|
+
|
|
11
|
+
## 三步
|
|
12
|
+
|
|
13
|
+
python3 scripts/release.py bump 2.10.1 # 改号(要求干净树 + main)
|
|
14
|
+
# 填 docs/RELEASE_NOTES_v2.10.1.md(去掉 TODO 标记)与五语 README 三块
|
|
15
|
+
python3 scripts/release.py check # 结构 + 内容 + 目录计数全绿
|
|
16
|
+
python3 scripts/release.py publish 2.10.1 --yes
|
|
17
|
+
|
|
18
|
+
内容段落(最近更新、能力段、发布表行)不自动生成:它们要判断和翻译。脚本
|
|
19
|
+
负责卡口——缺一段就不让发,而不是发出去再补。
|
|
20
|
+
|
|
21
|
+
常用开关:`--dry-run` 只打印;`publish --skip-tests/--skip-npm`;`--wait 600`
|
|
22
|
+
调大 registry 传播轮询秒数(npm CDN 3-4 分钟生效是正常现象)。
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from __future__ import annotations
|
|
26
|
+
|
|
27
|
+
import argparse
|
|
28
|
+
import json
|
|
29
|
+
import re
|
|
30
|
+
import shutil
|
|
31
|
+
import subprocess
|
|
32
|
+
import sys
|
|
33
|
+
import time
|
|
34
|
+
from pathlib import Path
|
|
35
|
+
|
|
36
|
+
ROOT = Path(__file__).resolve().parent.parent
|
|
37
|
+
sys.path.insert(0, str(ROOT / "scripts"))
|
|
38
|
+
|
|
39
|
+
import release_check # noqa: E402
|
|
40
|
+
|
|
41
|
+
README_LANGS = release_check.README_LANGS
|
|
42
|
+
NOTES_TODO = "<!-- release-todo -->"
|
|
43
|
+
VERSION_RE = re.compile(r"^\d+\.\d+\.\d+$")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class ReleaseError(RuntimeError):
|
|
47
|
+
"""发版前置条件不满足;main() 打到 stderr 并以非零退出。"""
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _read(root: Path, rel: str) -> str:
|
|
51
|
+
return (root / rel).read_text(encoding="utf-8")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _write(root: Path, rel: str, text: str) -> None:
|
|
55
|
+
(root / rel).write_text(text, encoding="utf-8", newline="\n")
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def current_version(root: Path = ROOT) -> str:
|
|
59
|
+
m = re.search(r'(?m)^version\s*=\s*"([^"]+)"', _read(root, "pyproject.toml"))
|
|
60
|
+
if not m:
|
|
61
|
+
raise ReleaseError("pyproject.toml 读不出 version")
|
|
62
|
+
return m.group(1)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def parse_version(v: str) -> tuple[int, int, int]:
|
|
66
|
+
if not VERSION_RE.match(v):
|
|
67
|
+
raise ReleaseError(f"版本号必须是 X.Y.Z 三段数字,收到 {v!r}")
|
|
68
|
+
return tuple(int(x) for x in v.split(".")) # type: ignore[return-value]
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# ── 改号规则:唯一一份「哪些地方写着版本号」的清单 ────────────────────────────
|
|
72
|
+
# 每条 (相对路径, 旧串, 新串, 期望出现次数);次数不对直接中止,避免误伤历史文案。
|
|
73
|
+
def rules(old: str, new: str) -> list[tuple[str, str, str, int]]:
|
|
74
|
+
o, n = old, new
|
|
75
|
+
out: list[tuple[str, str, str, int]] = [
|
|
76
|
+
("pyproject.toml", f'version = "{o}"', f'version = "{n}"', 1),
|
|
77
|
+
("package.json", f'"version": "{o}"', f'"version": "{n}"', 1),
|
|
78
|
+
("packages/dsh-plugin/package.json", f'"version": "{o}"', f'"version": "{n}"', 1),
|
|
79
|
+
("packages/marketplace.json", f'"version": "{o}"', f'"version": "{n}"', 1),
|
|
80
|
+
("packages/argo-zcode/.zcode-plugin/plugin.json",
|
|
81
|
+
f'"version": "{o}"', f'"version": "{n}"', 1),
|
|
82
|
+
("server.json", f'"version": "{o}"', f'"version": "{n}"', 2),
|
|
83
|
+
("argo_search/__init__.py", f'__version__ = "{o}"', f'__version__ = "{n}"', 1),
|
|
84
|
+
("SKILL.md", f"version: {o}", f"version: {n}", 1),
|
|
85
|
+
("scripts/mcp_transport.py", f'ARGO_MCP_VERSION = "{o}"', f'ARGO_MCP_VERSION = "{n}"', 1),
|
|
86
|
+
("packages/argo-zcode/server/panel_server.mjs",
|
|
87
|
+
f'version: "{o}"', f'version: "{n}"', 1),
|
|
88
|
+
("packages/argo-zcode/ui/panel.html", f'version: "{o}"', f'version: "{n}"', 1),
|
|
89
|
+
# 五语徽标
|
|
90
|
+
("README.md", f"badge/version-{o}-", f"badge/version-{n}-", 1),
|
|
91
|
+
("README.en.md", f"badge/version-{o}-", f"badge/version-{n}-", 1),
|
|
92
|
+
("README.ja.md", f"badge/version-{o}-", f"badge/version-{n}-", 1),
|
|
93
|
+
("README.ko.md", f"badge/version-{o}-", f"badge/version-{n}-", 1),
|
|
94
|
+
("README.es.md", f"badge/version-{o}-", f"badge/version-{n}-", 1),
|
|
95
|
+
# 五语「当前版本」散文(安装段两处)
|
|
96
|
+
("README.md", f"(已支持,当前 {o};按 tag 发布,版本固定)",
|
|
97
|
+
f"(已支持,当前 {n};按 tag 发布,版本固定)", 1),
|
|
98
|
+
("README.md", f"**npm 安装已支持,当前版本 {o}**",
|
|
99
|
+
f"**npm 安装已支持,当前版本 {n}**", 1),
|
|
100
|
+
("README.en.md", f"(supported, currently {o}; released per tag, version pinned)",
|
|
101
|
+
f"(supported, currently {n}; released per tag, version pinned)", 1),
|
|
102
|
+
("README.en.md", f"**npm install is supported, current version {o}**",
|
|
103
|
+
f"**npm install is supported, current version {n}**", 1),
|
|
104
|
+
("README.ja.md", f"現在 {o}。tag ごとに公開", f"現在 {n}。tag ごとに公開", 1),
|
|
105
|
+
("README.ja.md", f"**npm インストールに対応済みで、最新版は {o}**",
|
|
106
|
+
f"**npm インストールに対応済みで、最新版は {n}**", 1),
|
|
107
|
+
("README.ko.md", f"현재 {o}, tag마다 배포", f"현재 {n}, tag마다 배포", 1),
|
|
108
|
+
("README.ko.md", f"**npm 설치를 지원하며 최신 버전은 {o}**",
|
|
109
|
+
f"**npm 설치를 지원하며 최신 버전은 {n}**", 1),
|
|
110
|
+
("README.es.md", f"versión actual {o}; se publica por tag",
|
|
111
|
+
f"versión actual {n}; se publica por tag", 1),
|
|
112
|
+
("README.es.md", f"**La instalación por npm está soportada y la versión actual es {o}**",
|
|
113
|
+
f"**La instalación por npm está soportada y la versión actual es {n}**", 1),
|
|
114
|
+
# 五语「当前大致能力」标题
|
|
115
|
+
("README.md", f"### 当前大致能力(v{o})", f"### 当前大致能力(v{n})", 1),
|
|
116
|
+
("README.en.md", f"### Rough capability set (v{o})", f"### Rough capability set (v{n})", 1),
|
|
117
|
+
("README.ja.md", f"### 現時点の能力概要(v{o})", f"### 現時点の能力概要(v{n})", 1),
|
|
118
|
+
("README.ko.md", f"### 대략적인 능력 세트 (v{o})", f"### 대략적인 능력 세트 (v{n})", 1),
|
|
119
|
+
("README.es.md", f"### Conjunto aproximado de capacidades (v{o})",
|
|
120
|
+
f"### Conjunto aproximado de capacidades (v{n})", 1),
|
|
121
|
+
]
|
|
122
|
+
return out
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def apply_rules(root: Path, old: str, new: str, dry: bool) -> list[str]:
|
|
126
|
+
"""按 rules 改写;任何一处次数不符就整体中止(返回已计划清单)。"""
|
|
127
|
+
planned: list[str] = []
|
|
128
|
+
for rel, o, n, want in rules(old, new):
|
|
129
|
+
path = root / rel
|
|
130
|
+
if not path.is_file():
|
|
131
|
+
raise ReleaseError(f"{rel}: 文件不存在,无法改号")
|
|
132
|
+
text = path.read_text(encoding="utf-8")
|
|
133
|
+
got = text.count(o)
|
|
134
|
+
if got != want:
|
|
135
|
+
raise ReleaseError(f"{rel}: {o!r} 出现 {got} 次(期望 {want})——先确认模板没变")
|
|
136
|
+
planned.append(f"{rel}: {o} -> {n}")
|
|
137
|
+
if not dry:
|
|
138
|
+
path.write_text(text.replace(o, n), encoding="utf-8", newline="\n")
|
|
139
|
+
return planned
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def ensure_whitelist(root: Path, old: str, new: str, dry: bool) -> str:
|
|
143
|
+
"""package.json files 白名单补新发布说明(锚在旧版条目上)。"""
|
|
144
|
+
rel = "package.json"
|
|
145
|
+
text = _read(root, rel)
|
|
146
|
+
old_entry = f' "docs/RELEASE_NOTES_v{old}.md",\n'
|
|
147
|
+
new_entry = f' "docs/RELEASE_NOTES_v{new}.md",\n'
|
|
148
|
+
if new_entry in text:
|
|
149
|
+
return f"{rel}: 白名单已含 v{new},跳过"
|
|
150
|
+
if old_entry not in text:
|
|
151
|
+
raise ReleaseError(f"{rel}: 找不到 v{old} 的发布说明条目,无法定位插入点")
|
|
152
|
+
if not dry:
|
|
153
|
+
_write(root, rel, text.replace(old_entry, new_entry + old_entry, 1))
|
|
154
|
+
return f"{rel}: 白名单插入 docs/RELEASE_NOTES_v{new}.md"
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def ensure_notes(root: Path, new: str, dry: bool) -> str:
|
|
158
|
+
"""发布说明不存在时生成带 TODO 标记的骨架,避免结构性预检红。"""
|
|
159
|
+
rel = f"docs/RELEASE_NOTES_v{new}.md"
|
|
160
|
+
path = root / rel
|
|
161
|
+
if path.is_file():
|
|
162
|
+
return f"{rel}: 已存在"
|
|
163
|
+
if not dry:
|
|
164
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
165
|
+
path.write_text(
|
|
166
|
+
f"# Argo v{new} 发布说明\n\n{NOTES_TODO}\n\n"
|
|
167
|
+
"**版本**:%s\n**定位**:\n\n---\n\n"
|
|
168
|
+
"## 这次更新有什么(通俗版)\n\n## 验证\n\n## 兼容性\n" % new,
|
|
169
|
+
encoding="utf-8", newline="\n")
|
|
170
|
+
return f"{rel}: 生成骨架(记得去掉 {NOTES_TODO})"
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
# ── 内容清单:脚本不写文案,但缺一段就不让发 ────────────────────────────────
|
|
174
|
+
def content_problems(root: Path, ver: str) -> list[str]:
|
|
175
|
+
problems: list[str] = []
|
|
176
|
+
notes = root / f"docs/RELEASE_NOTES_v{ver}.md"
|
|
177
|
+
if not notes.is_file():
|
|
178
|
+
problems.append(f"docs/RELEASE_NOTES_v{ver}.md: 发布说明不存在")
|
|
179
|
+
elif NOTES_TODO in notes.read_text(encoding="utf-8"):
|
|
180
|
+
problems.append(f"docs/RELEASE_NOTES_v{ver}.md: 仍是骨架({NOTES_TODO} 未删)")
|
|
181
|
+
for rel in README_LANGS:
|
|
182
|
+
text = _read(root, rel)
|
|
183
|
+
if not re.search(rf"(?m)^### v{re.escape(ver)}", text):
|
|
184
|
+
problems.append(f"{rel}: 缺「最近更新」段(### v{ver})")
|
|
185
|
+
if f"| **v{ver}** |" not in text:
|
|
186
|
+
problems.append(f"{rel}: 发布记录表缺 | **v{ver}** | 行")
|
|
187
|
+
if not re.search(rf"(?m)^### [^\n]*[{re.escape(ver)}))]", text):
|
|
188
|
+
problems.append(f"{rel}: 「当前大致能力」标题未跟进到 v{ver}")
|
|
189
|
+
if not re.search(rf"(?m)^v{re.escape(ver)}", text):
|
|
190
|
+
problems.append(f"{rel}: 能力段缺以 v{ver} 开头的新段落")
|
|
191
|
+
return problems
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def catalog_stale(root: Path) -> str:
|
|
195
|
+
r = subprocess.run(
|
|
196
|
+
[sys.executable, str(root / "scripts" / "gen_engine_catalog.py"), "--check"],
|
|
197
|
+
cwd=root, capture_output=True, text=True, encoding="utf-8", errors="replace")
|
|
198
|
+
if r.returncode == 0:
|
|
199
|
+
return ""
|
|
200
|
+
out = (r.stdout + r.stderr).strip()
|
|
201
|
+
if "No module named 'yaml'" in out or "No module named yaml" in out:
|
|
202
|
+
out += "\n(当前解释器缺 PyYAML;用 python3.14 跑本脚本)"
|
|
203
|
+
return out
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def check(root: Path = ROOT) -> list[str]:
|
|
207
|
+
"""全量校验:结构(release_check)+ 内容清单 + 目录计数。"""
|
|
208
|
+
ver = current_version(root)
|
|
209
|
+
problems = [f"release_check: {p}" for p in release_check.check(root)]
|
|
210
|
+
problems += content_problems(root, ver)
|
|
211
|
+
stale = catalog_stale(root)
|
|
212
|
+
if stale:
|
|
213
|
+
problems.append(f"目录计数: {stale}")
|
|
214
|
+
return problems
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
# ── git 前置 ────────────────────────────────────────────────────────────────
|
|
218
|
+
def _git(root: Path, *args: str) -> subprocess.CompletedProcess[str]:
|
|
219
|
+
return subprocess.run(["git", *args], cwd=root, capture_output=True, text=True, encoding="utf-8", errors="replace")
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def _is_git_repo(root: Path) -> bool:
|
|
223
|
+
return _git(root, "rev-parse", "--is-inside-work-tree").stdout.strip() == "true"
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def preflight(root: Path, new: str, force_branch: bool, git_checks: bool) -> None:
|
|
227
|
+
old = current_version(root)
|
|
228
|
+
if parse_version(new) <= parse_version(old):
|
|
229
|
+
raise ReleaseError(f"新版本 {new} 必须大于当前 {old}")
|
|
230
|
+
if not git_checks or not _is_git_repo(root):
|
|
231
|
+
return
|
|
232
|
+
dirty = _git(root, "status", "--porcelain").stdout.strip()
|
|
233
|
+
if dirty:
|
|
234
|
+
raise ReleaseError("工作区不干净——先提交或 stash,再改号(保证发版 diff 可审)")
|
|
235
|
+
branch = _git(root, "rev-parse", "--abbrev-ref", "HEAD").stdout.strip()
|
|
236
|
+
if branch != "main" and not force_branch:
|
|
237
|
+
raise ReleaseError(f"当前分支 {branch},发版请在 main(或用 --force-branch)")
|
|
238
|
+
if _git(root, "rev-parse", "-q", "--verify", f"refs/tags/v{new}").returncode == 0:
|
|
239
|
+
raise ReleaseError(f"标签 v{new} 已存在")
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def bump(root: Path, new: str, dry: bool = False, force_branch: bool = False,
|
|
243
|
+
git_checks: bool = True) -> list[str]:
|
|
244
|
+
old = current_version(root)
|
|
245
|
+
preflight(root, new, force_branch, git_checks)
|
|
246
|
+
msgs = [f"版本 {old} -> {new}"]
|
|
247
|
+
msgs += apply_rules(root, old, new, dry)
|
|
248
|
+
msgs.append(ensure_whitelist(root, old, new, dry))
|
|
249
|
+
msgs.append(ensure_notes(root, new, dry))
|
|
250
|
+
return msgs
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
# ── 发布 ────────────────────────────────────────────────────────────────────
|
|
254
|
+
def _npm_version_exists(pkg: str, ver: str) -> bool:
|
|
255
|
+
r = subprocess.run(["npm", "view", f"{pkg}@{ver}", "version"],
|
|
256
|
+
capture_output=True, text=True, encoding="utf-8", errors="replace")
|
|
257
|
+
return r.returncode == 0
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def _npm_publish(root: Path, cwd_rel: str, pkg: str, ver: str, extra: list[str]) -> None:
|
|
261
|
+
if _npm_version_exists(pkg, ver):
|
|
262
|
+
print(f" - {pkg}@{ver} 已在 registry,跳过")
|
|
263
|
+
return
|
|
264
|
+
r = subprocess.run(["npm", "publish", *extra], cwd=root / cwd_rel, text=True, encoding="utf-8", errors="replace")
|
|
265
|
+
if r.returncode != 0:
|
|
266
|
+
raise ReleaseError(f"npm publish {pkg} 失败(退出码 {r.returncode})")
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
def _wait_npm(pkg: str, ver: str, timeout: int) -> bool:
|
|
270
|
+
start = time.time()
|
|
271
|
+
while time.time() - start < timeout:
|
|
272
|
+
r = subprocess.run(["npm", "view", pkg, "dist-tags.latest"],
|
|
273
|
+
capture_output=True, text=True, encoding="utf-8", errors="replace")
|
|
274
|
+
if r.stdout.strip() == ver:
|
|
275
|
+
print(f" - {pkg} latest = {ver}({int(time.time() - start)}s)")
|
|
276
|
+
return True
|
|
277
|
+
time.sleep(10)
|
|
278
|
+
print(f" !! {pkg} 的 latest 在 {timeout}s 内未变成 {ver}(CDN 传播,勿重发)")
|
|
279
|
+
return False
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def _wait_release(ver: str, timeout: int) -> str:
|
|
283
|
+
start = time.time()
|
|
284
|
+
while time.time() - start < timeout:
|
|
285
|
+
r = subprocess.run(
|
|
286
|
+
["gh", "release", "view", f"v{ver}", "--json", "url,assets"],
|
|
287
|
+
capture_output=True, text=True, encoding="utf-8", errors="replace")
|
|
288
|
+
if r.returncode == 0:
|
|
289
|
+
data = json.loads(r.stdout)
|
|
290
|
+
assets = ", ".join(a["name"] for a in data.get("assets", []))
|
|
291
|
+
return f"{data.get('url', '')}(资产:{assets})"
|
|
292
|
+
time.sleep(10)
|
|
293
|
+
return ""
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def publish(root: Path, new: str, yes: bool = False, skip_tests: bool = False,
|
|
297
|
+
skip_npm: bool = False, wait: int = 300, dry: bool = False) -> None:
|
|
298
|
+
ver = current_version(root)
|
|
299
|
+
if ver != new:
|
|
300
|
+
raise ReleaseError(f"仓库当前是 {ver},与要发布的 {new} 不一致——先 bump")
|
|
301
|
+
problems = check(root)
|
|
302
|
+
if problems:
|
|
303
|
+
raise ReleaseError("校验未过:\n - " + "\n - ".join(problems))
|
|
304
|
+
plan = [
|
|
305
|
+
"pytest 全量" if not skip_tests else "pytest 跳过",
|
|
306
|
+
f"git commit + tag v{ver} + push main/tag",
|
|
307
|
+
"npm publish argo-search + @taxueseek/argo-dsh" if not skip_npm else "npm 跳过",
|
|
308
|
+
f"轮询 registry 与 GitHub Release(最多 {wait}s)",
|
|
309
|
+
]
|
|
310
|
+
if dry:
|
|
311
|
+
print("dry-run,将执行:\n - " + "\n - ".join(plan))
|
|
312
|
+
return
|
|
313
|
+
if not yes:
|
|
314
|
+
raise ReleaseError("发布是对外动作,确认后加 --yes 重跑:\n - " + "\n - ".join(plan))
|
|
315
|
+
|
|
316
|
+
if not skip_tests:
|
|
317
|
+
r = subprocess.run([sys.executable, "-m", "pytest", "-q"], cwd=root, text=True, encoding="utf-8", errors="replace")
|
|
318
|
+
if r.returncode != 0:
|
|
319
|
+
raise ReleaseError("pytest 未过,已停止")
|
|
320
|
+
|
|
321
|
+
if _is_git_repo(root):
|
|
322
|
+
if _git(root, "status", "--porcelain").stdout.strip():
|
|
323
|
+
_git(root, "add", "-A")
|
|
324
|
+
msg = f"docs(release): v{ver} 发布说明 + 版本号与五语 README 统一 {ver}"
|
|
325
|
+
r = _git(root, "commit", "-m", msg)
|
|
326
|
+
if r.returncode != 0:
|
|
327
|
+
raise ReleaseError(f"git commit 失败:{r.stderr.strip()}")
|
|
328
|
+
if _git(root, "rev-parse", "-q", "--verify", f"refs/tags/v{ver}").returncode != 0:
|
|
329
|
+
r = _git(root, "tag", f"v{ver}")
|
|
330
|
+
if r.returncode != 0:
|
|
331
|
+
raise ReleaseError(f"git tag 失败:{r.stderr.strip()}")
|
|
332
|
+
for args in (("push", "origin", "main"), ("push", "origin", f"v{ver}")):
|
|
333
|
+
r = _git(root, *args)
|
|
334
|
+
if r.returncode != 0:
|
|
335
|
+
raise ReleaseError(f"git {args[0]} {args[-1]} 失败:{r.stderr.strip()}")
|
|
336
|
+
print(f" - 已推送 main 与 tag v{ver}")
|
|
337
|
+
|
|
338
|
+
if not skip_npm:
|
|
339
|
+
_npm_publish(root, ".", "argo-search", ver, [])
|
|
340
|
+
_npm_publish(root, "packages/dsh-plugin", "@taxueseek/argo-dsh",
|
|
341
|
+
ver, ["--access", "public"])
|
|
342
|
+
_wait_npm("argo-search", ver, wait)
|
|
343
|
+
_wait_npm("@taxueseek/argo-dsh", ver, wait)
|
|
344
|
+
|
|
345
|
+
release = _wait_release(ver, wait)
|
|
346
|
+
print(f" - GitHub Release: {release or '未在等待时间内出现(看 Actions 的 release 工作流)'}")
|
|
347
|
+
print(f"发布完成:v{ver}")
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
def main(argv: list[str] | None = None) -> int:
|
|
351
|
+
ap = argparse.ArgumentParser(description="Argo 发版一条链")
|
|
352
|
+
sub = ap.add_subparsers(dest="cmd", required=True)
|
|
353
|
+
|
|
354
|
+
b = sub.add_parser("bump", help="改版本号(含发布说明骨架)")
|
|
355
|
+
b.add_argument("version")
|
|
356
|
+
b.add_argument("--dry-run", action="store_true")
|
|
357
|
+
b.add_argument("--force-branch", action="store_true")
|
|
358
|
+
b.add_argument("--no-git-checks", action="store_true", help=argparse.SUPPRESS)
|
|
359
|
+
|
|
360
|
+
c = sub.add_parser("check", help="结构 + 内容 + 目录计数校验")
|
|
361
|
+
|
|
362
|
+
p = sub.add_parser("publish", help="测试 → 提交 → 打标签 → 发 npm → 轮询核验")
|
|
363
|
+
p.add_argument("version")
|
|
364
|
+
p.add_argument("--yes", action="store_true", help="确认对外发布")
|
|
365
|
+
p.add_argument("--skip-tests", action="store_true")
|
|
366
|
+
p.add_argument("--skip-npm", action="store_true")
|
|
367
|
+
p.add_argument("--wait", type=int, default=300)
|
|
368
|
+
p.add_argument("--dry-run", action="store_true")
|
|
369
|
+
|
|
370
|
+
args = ap.parse_args(argv)
|
|
371
|
+
try:
|
|
372
|
+
if args.cmd == "bump":
|
|
373
|
+
for line in bump(ROOT, args.version, args.dry_run,
|
|
374
|
+
args.force_branch, not args.no_git_checks):
|
|
375
|
+
print(f" - {line}")
|
|
376
|
+
if args.dry_run:
|
|
377
|
+
print("dry-run,未写入")
|
|
378
|
+
else:
|
|
379
|
+
print("\n下一步:填发布说明与五语 README 三块,然后 release.py check")
|
|
380
|
+
elif args.cmd == "check":
|
|
381
|
+
problems = check(ROOT)
|
|
382
|
+
if problems:
|
|
383
|
+
print(f"release.py check: {len(problems)} 项待修", file=sys.stderr)
|
|
384
|
+
for x in problems:
|
|
385
|
+
print(f" !! {x}", file=sys.stderr)
|
|
386
|
+
return 1
|
|
387
|
+
print(f"release.py check: v{current_version(ROOT)} 全绿")
|
|
388
|
+
else:
|
|
389
|
+
publish(ROOT, args.version, args.yes, args.skip_tests,
|
|
390
|
+
args.skip_npm, args.wait, args.dry_run)
|
|
391
|
+
except ReleaseError as e:
|
|
392
|
+
print(f"release.py: {e}", file=sys.stderr)
|
|
393
|
+
return 1
|
|
394
|
+
return 0
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
if __name__ == "__main__":
|
|
398
|
+
sys.exit(main())
|
package/scripts/route_domains.py
CHANGED
|
@@ -220,10 +220,26 @@ def _pattern_entries(domain: dict[str, Any]) -> list[Any]:
|
|
|
220
220
|
return list(patterns) if isinstance(patterns, list) else []
|
|
221
221
|
|
|
222
222
|
|
|
223
|
+
# 声明式否决宏(2026-10-29,issue #34.1):蛋白/化合物/通用医疗词汇在「市场规模/
|
|
224
|
+
# 销售额/集采/医保」等商业研报语境下不是查生信/化学/临床试验库。把公共商业否决集
|
|
225
|
+
# 抽成命名宏 `@commercial_market`,在 config.yaml 的 unless 字段按需引用,消除多域
|
|
226
|
+
# 重复粘贴并保持 `_split_pattern_entry` 单点展开。
|
|
227
|
+
_UNLESS_MACROS: dict[str, str] = {
|
|
228
|
+
"@commercial_market": (
|
|
229
|
+
r"(?i)(市场规模|市场份额|销售额|营收|市值|融资|财报|竞争格局|集采|医保|报销|"
|
|
230
|
+
r"价格|多少钱|商业化|市场预测|行情|股价|龙头股|概念股|"
|
|
231
|
+
r"market\s+size|market\s+share|sales|revenue|valuation|market\s+forecast|pricing)"
|
|
232
|
+
),
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
|
|
223
236
|
def _split_pattern_entry(entry: Any) -> tuple[Any, Any]:
|
|
224
|
-
"""触发词条目的两种形态:字符串,或 `{match, unless}
|
|
237
|
+
"""触发词条目的两种形态:字符串,或 `{match, unless}`(unless 支持 @宏名 展开)。"""
|
|
225
238
|
if isinstance(entry, dict):
|
|
226
|
-
|
|
239
|
+
unless = entry.get("unless")
|
|
240
|
+
if isinstance(unless, str) and unless in _UNLESS_MACROS:
|
|
241
|
+
unless = _UNLESS_MACROS[unless]
|
|
242
|
+
return entry.get("match"), unless
|
|
227
243
|
return entry, None
|
|
228
244
|
|
|
229
245
|
|
package/scripts/search.py
CHANGED
|
@@ -571,6 +571,7 @@ def super_search(query: str, engine: str = "auto", n: int = 5, explain: bool = F
|
|
|
571
571
|
exclude_domains: list[str] | None = None,
|
|
572
572
|
engine_domain: str | None = None,
|
|
573
573
|
engine_sub_domain: str | None = None,
|
|
574
|
+
quiet: bool = False,
|
|
574
575
|
timing: StageTiming | None = None) -> dict[str, Any]:
|
|
575
576
|
"""统一搜索便捷入口。
|
|
576
577
|
|
|
@@ -787,7 +788,8 @@ def super_search(query: str, engine: str = "auto", n: int = 5, explain: bool = F
|
|
|
787
788
|
_local_seek_future = None
|
|
788
789
|
if include_local:
|
|
789
790
|
_local_seek_future = _get_local_seek_executor().submit(
|
|
790
|
-
_run_local_seek, query, n, warn=_local_seek_explicit
|
|
791
|
+
_run_local_seek, query, n, warn=_local_seek_explicit,
|
|
792
|
+
echo=not quiet)
|
|
791
793
|
|
|
792
794
|
result = execute_search(
|
|
793
795
|
query=search_query, decision=decision, max_results=n,
|
|
@@ -921,7 +923,7 @@ def super_search(query: str, engine: str = "auto", n: int = 5, explain: bool = F
|
|
|
921
923
|
timeout=max(_local_deadline - time.monotonic(), 0))
|
|
922
924
|
except Exception:
|
|
923
925
|
return []
|
|
924
|
-
return _run_local_seek(q, max_n, search_dir)
|
|
926
|
+
return _run_local_seek(q, max_n, search_dir, echo=not quiet)
|
|
925
927
|
|
|
926
928
|
result = shape_response(_ShapeContext(
|
|
927
929
|
query=query, kind=kind, tier=tier, envelope=envelope, decision=decision,
|
package/scripts/search_cli.py
CHANGED
|
@@ -307,6 +307,7 @@ def _summarize_engine_rows(rows: list[dict[str, Any]]) -> dict[str, Any]:
|
|
|
307
307
|
blocked.append({
|
|
308
308
|
"engine_id": name,
|
|
309
309
|
"reason": reason,
|
|
310
|
+
**({"disabled_reason": row["disabled_reason"]} if row.get("disabled_reason") else {}),
|
|
310
311
|
**({"missing_env": row["missing_env"]} if row.get("missing_env") else {}),
|
|
311
312
|
**({"missing_deps": row["missing_deps"]} if row.get("missing_deps") else {}),
|
|
312
313
|
**({"status": row["status"]} if row.get("status") else {}),
|
|
@@ -378,6 +379,14 @@ def main():
|
|
|
378
379
|
parser = build_parser()
|
|
379
380
|
args = parser.parse_args()
|
|
380
381
|
|
|
382
|
+
if args.json_output:
|
|
383
|
+
# issue #34 第 7 条:引擎 builder 的 logger.warning(如「OCTEN_API_KEY
|
|
384
|
+
# 未设置」)经 logging 的最后兜底 handler 打到 stderr,调用方一旦
|
|
385
|
+
# 2>&1 合并就解析失败。JSON 模式只留 ERROR:非致命告警静默,可行动
|
|
386
|
+
# 的告警走响应里的 warnings[] 字段(见 search.super_search 的 quiet)。
|
|
387
|
+
import logging
|
|
388
|
+
logging.disable(logging.WARNING)
|
|
389
|
+
|
|
381
390
|
if args.list_engines:
|
|
382
391
|
# --engine 兼作清单过滤(`--engine auto` 是搜索默认值,不算过滤)。
|
|
383
392
|
# 全量详细行 2026-09-16 实测 151 KB(runtime/admission 嵌套是大头),
|
|
@@ -435,6 +444,15 @@ def main():
|
|
|
435
444
|
if _wanted:
|
|
436
445
|
names = [n for n in names if n in set(_wanted)]
|
|
437
446
|
print(dumps(names))
|
|
447
|
+
# issue #34 第 6 条:本档只回答「有多少个有实现的源」,与
|
|
448
|
+
# `paths --check` 的 engines=<总收录> 天然不等——差额里是
|
|
449
|
+
# 停用/缺密钥/别名 spec。以前这层口径差没有任何对外说明,
|
|
450
|
+
# 被当成计数错误。提示走 stderr,stdout 保持纯 JSON 名单。
|
|
451
|
+
if not _wanted:
|
|
452
|
+
print(f"[list-engines] 有实现的源 {len(names)} 个(routes 实际可用数)"
|
|
453
|
+
";总收录与每个不可用项的成因见 --list-engines --detail,"
|
|
454
|
+
"逐条全量清单加 --all;paths --check 的 engines= 是总收录口径",
|
|
455
|
+
file=sys.stderr)
|
|
438
456
|
return
|
|
439
457
|
|
|
440
458
|
# 入口级引擎名校验(2026-10-10 方案甲):无效名字此前只在执行层补 errors,
|
|
@@ -538,6 +556,10 @@ def main():
|
|
|
538
556
|
# 交回 super_search 后自动获得 L1 并行提交(与主搜索同时跑)。
|
|
539
557
|
include_local=(True if args.include_local
|
|
540
558
|
else (False if args.no_local else None)),
|
|
559
|
+
# --json 时 stderr 会被调用方 2>&1 合并,非致命告警(缺 key、宽根跳过
|
|
560
|
+
# 等)一律不进 stderr(issue #34 第 7 条);可行动的告警随响应
|
|
561
|
+
# 的 warnings[] 字段返回。
|
|
562
|
+
quiet=args.json_output,
|
|
541
563
|
)
|
|
542
564
|
|
|
543
565
|
# 固定开销(import + argparse + 收尾):缓存命中时它占墙钟大头,而它不出现
|
package/scripts/search_output.py
CHANGED
|
@@ -161,6 +161,10 @@ def _strip_for_agent(payload: dict[str, Any]) -> dict[str, Any]:
|
|
|
161
161
|
# limitations/recovery/time_filter_warning 一并剥掉,agent 无从判断
|
|
162
162
|
# 「这批结果能用到什么程度」(2026-09-15 输出契约审查)。
|
|
163
163
|
"limitations", "recovery", "time_filter_warning",
|
|
164
|
+
# 搜索期告警(issue #34 第 7 条):--json 管道场景默认走 agent 档,
|
|
165
|
+
# 告警只在 warnings[] 里——剥掉它等于「静默跳过」再次发生,且调用方
|
|
166
|
+
# 从 JSON 里永远看不到「本机检索没执行/缺 seek.py」的原因。
|
|
167
|
+
"warnings",
|
|
164
168
|
# 阶段耗时:默认就带(--no-timing 才没有)。剥掉会让使用者看不到
|
|
165
169
|
# 「这次慢在哪」,也拿不到自己动手优化所需的依据。
|
|
166
170
|
"timing",
|
|
@@ -716,4 +720,14 @@ def shape_response(ctx: _ShapeContext, result: dict[str, Any]) -> dict[str, Any]
|
|
|
716
720
|
result["content_trust"] = CONTENT_TRUST_UNTRUSTED
|
|
717
721
|
except Exception:
|
|
718
722
|
pass
|
|
723
|
+
# 搜索期告警(issue #34 第 7 条):--json 下告警不能留在 stderr(调用方
|
|
724
|
+
# 2>&1 合并会破坏 JSON 解析),统一收进响应的 warnings[] 字段。住在
|
|
725
|
+
# 响应契约层而不是 search.py:所有入口共享同一收口。空账不加键。
|
|
726
|
+
try:
|
|
727
|
+
from local_seek import drain_search_warnings
|
|
728
|
+
warns = [w.strip() for w in drain_search_warnings() if w.strip()]
|
|
729
|
+
if warns:
|
|
730
|
+
result.setdefault("warnings", []).extend(warns)
|
|
731
|
+
except Exception:
|
|
732
|
+
pass
|
|
719
733
|
return result
|
|
@@ -384,8 +384,10 @@ def postprocess(req: _SearchRequest, run: _SearchRun, hooks: Any) -> _SearchRun:
|
|
|
384
384
|
_funnel_deduped = len(merged)
|
|
385
385
|
if merged:
|
|
386
386
|
try:
|
|
387
|
-
from serp_guard import
|
|
388
|
-
|
|
387
|
+
from serp_guard import is_unusable_row as _is_unusable_row # SERP + 内容农场,标定见 test_content_farm_guard.py
|
|
388
|
+
# url_kind: none(issue #29 口径 B):spec 显式声明条目不以 url 为身份,
|
|
389
|
+
# 缺 url 的题录/语义片段不再被当壳页整批吞
|
|
390
|
+
merged = [r for r in merged if not _is_unusable_row(r)]
|
|
389
391
|
except ImportError:
|
|
390
392
|
pass # serp_guard 不可用时跳过(本地五维 rerank 已对 SERP 降权)
|
|
391
393
|
|
package/scripts/search_rank.py
CHANGED
|
@@ -725,7 +725,9 @@ def local_five_dim_rerank(query: str, results: list[dict[str, Any]],
|
|
|
725
725
|
relevance = max(relevance, fl["relevance"])
|
|
726
726
|
if _has_evidence:
|
|
727
727
|
try:
|
|
728
|
-
|
|
728
|
+
# 传 query:有条件降权(如裁判文书站只在法律语境保留高分)要
|
|
729
|
+
# 看提问本身,而不是只看域名。
|
|
730
|
+
authority = float(score_authority(url, source, query).get("score", 0.5))
|
|
729
731
|
except Exception:
|
|
730
732
|
authority = 0.5
|
|
731
733
|
try:
|
package/scripts/serp_guard.py
CHANGED
|
@@ -318,6 +318,17 @@ def is_unusable_url(url: str, title: str = "", snippet: str = "") -> bool:
|
|
|
318
318
|
return is_content_farm(url, title, snippet)
|
|
319
319
|
|
|
320
320
|
|
|
321
|
+
def is_unusable_row(row: dict) -> bool:
|
|
322
|
+
"""条目级闸(issue #29 口径 B):spec 声明 url_kind: none 的条目不以 url 为
|
|
323
|
+
身份,空 url 不判壳页;一旦有 url,SERP 判据照走;内容农场判据恒走。"""
|
|
324
|
+
if row.get("url_kind") == "none":
|
|
325
|
+
url = row.get("url", "")
|
|
326
|
+
if url and is_serp_or_jump_url(url):
|
|
327
|
+
return True
|
|
328
|
+
return is_content_farm(url, row.get("title", ""), row.get("snippet", ""))
|
|
329
|
+
return is_unusable_url(row.get("url", ""), row.get("title", ""), row.get("snippet", ""))
|
|
330
|
+
|
|
331
|
+
|
|
321
332
|
def filter_content_farms(results: list) -> list:
|
|
322
333
|
"""过滤结果列表里的内容农场条目。"""
|
|
323
334
|
if not results or not guard_enabled():
|
package/scripts/url_canon.py
CHANGED
|
@@ -47,11 +47,12 @@ TRACKING_PARAMS: frozenset[str] = frozenset({
|
|
|
47
47
|
"from_source", "from_spmid", "from_spmid2", "vd_source", "unique_k",
|
|
48
48
|
"buvid", "buvid3", "buvid4", "up_id", "seid", "spmid", "timestamp",
|
|
49
49
|
"wxshare", "weibo_id", "share_referer", "share_object_id",
|
|
50
|
-
#
|
|
50
|
+
# 通用归因与平台语言/分享变体(YouTube vl/si 会把同一视频拆成多条重复 URL)
|
|
51
51
|
"ref", "ref_src", "ref_url", "refer", "referer", "referrer",
|
|
52
52
|
"source", "from", "src", "cmp", "camp", "srsltid",
|
|
53
53
|
"clickid", "click_id", "clicktime", "scid", "scene", "sessionid",
|
|
54
54
|
"trace", "trace_id", "track", "tracking_id", "trk", "trkcampaign",
|
|
55
|
+
"si", "vl",
|
|
55
56
|
})
|
|
56
57
|
|
|
57
58
|
# 移动站/AMP 子域前缀(fold_mobile)与 www 前缀(fold_www)分开——
|
package/scripts/video_route.py
CHANGED
|
@@ -17,9 +17,9 @@ from __future__ import annotations
|
|
|
17
17
|
|
|
18
18
|
from typing import Any
|
|
19
19
|
|
|
20
|
-
# config 缺 video 域时的兜底:B
|
|
21
|
-
#
|
|
22
|
-
_FALLBACK = ("bilibili", "anysearch")
|
|
20
|
+
# config 缺 video 域时的兜底:B 站负责中文视频,parallel_free 负责海外/YouTube
|
|
21
|
+
# 视频(免 Key 直连),anysearch 补充国内综合索引。
|
|
22
|
+
_FALLBACK = ("bilibili", "parallel_free", "anysearch")
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
def _video_domain() -> dict[str, Any]:
|
|
@@ -1172,15 +1172,30 @@ def git_blame(path, line, timeout=None):
|
|
|
1172
1172
|
|
|
1173
1173
|
def _run_grep_fallback(args, patterns, fixed, path, excludes, exts, max_results,
|
|
1174
1174
|
timeout=None, since_ts=None, until_ts=None):
|
|
1175
|
-
"""rg 缺失时的 grep 保底(目录内/全盘共用)。
|
|
1175
|
+
"""rg 缺失时的 FTS5 / grep 保底(目录内/全盘共用)。
|
|
1176
1176
|
|
|
1177
|
-
返回 (results, err, mode);
|
|
1178
|
-
|
|
1177
|
+
返回 (results, err, mode);FTS5 索引命中时优先走标准库 sqlite3(免外部工具),
|
|
1178
|
+
rg 与 grep 都不可用且无 FTS5 索引时 results=None 且 err 说明缺什么——
|
|
1179
|
+
调用方必须把「工具缺失」与「未找到匹配」区分开。
|
|
1179
1180
|
"""
|
|
1181
|
+
dots = getattr(args, "dot", False)
|
|
1182
|
+
if not exts and not getattr(args, "exclude", None) and not args.count and args.context == 0:
|
|
1183
|
+
try:
|
|
1184
|
+
import seek_fts
|
|
1185
|
+
except ImportError:
|
|
1186
|
+
seek_fts = None
|
|
1187
|
+
if seek_fts is not None and seek_fts.query_suitable(args.query):
|
|
1188
|
+
rows = seek_fts.content_candidates(
|
|
1189
|
+
args.query, path, dots=dots,
|
|
1190
|
+
since_ts=since_ts, until_ts=until_ts)
|
|
1191
|
+
if rows is not None:
|
|
1192
|
+
return _finish_content(
|
|
1193
|
+
iter(rows), args.query, args.context, args.count,
|
|
1194
|
+
fixed, path, max_results, not args.include_noise
|
|
1195
|
+
), None, "fts"
|
|
1180
1196
|
grep_exe = resolve_grep()
|
|
1181
1197
|
if not grep_exe:
|
|
1182
1198
|
return None, "本机无 rg 与 grep 可用,请安装 ripgrep", ""
|
|
1183
|
-
dots = getattr(args, "dot", False)
|
|
1184
1199
|
mode = "fast"
|
|
1185
1200
|
if not args.exact and len(patterns) > 1:
|
|
1186
1201
|
results, err = grep_search(grep_exe, [args.query], path, excludes, exts,
|