argo-search 2.10.0 → 2.10.2
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 +50 -10
- package/README.es.md +49 -9
- package/README.ja.md +50 -10
- package/README.ko.md +50 -10
- package/README.md +50 -30
- package/SKILL.md +11 -10
- package/backends/concept_vectors.bin +0 -0
- package/backends/engine_concept_vectors.json +3104 -0
- package/backends/engine_registry.yaml +2 -2
- package/backends/source_types_cn.json +9 -0
- package/config.yaml +105 -24
- package/docs/ENGINE_CATALOG.md +8 -8
- package/docs/RELEASE_NOTES_v2.10.1.md +57 -0
- package/docs/RELEASE_NOTES_v2.10.2.md +48 -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 +4 -2
- package/packages/dsh-plugin/dsh/diagnostics.js +8 -3
- package/packages/dsh-plugin/dsh/index.js +7 -7
- package/packages/dsh-plugin/dsh/runner.js +72 -46
- package/packages/dsh-plugin/package.json +1 -1
- package/packages/dsh-plugin/test/index.test.js +43 -0
- package/scripts/argo_engine_registry.py +30 -4
- package/scripts/argo_paths.py +7 -1
- package/scripts/build_concept_table.py +612 -0
- package/scripts/build_route_labels.py +285 -0
- package/scripts/caliber_dedupe.py +66 -0
- package/scripts/caliber_isolation.py +4 -2
- package/scripts/ci_drift_gate.py +47 -24
- package/scripts/circuit_breaker.py +25 -3
- package/scripts/concept_lookup.py +212 -0
- package/scripts/engine_dispatch.py +6 -8
- package/scripts/engine_status.py +12 -5
- package/scripts/engines.py +29 -7
- package/scripts/engines_base.py +48 -17
- package/scripts/engines_builders_data.py +10 -3
- package/scripts/engines_builders_skill.py +87 -10
- package/scripts/evidence.py +26 -5
- package/scripts/extend_route_labels.py +239 -0
- package/scripts/extend_route_labels_by_capability.py +344 -0
- package/scripts/gen_routing_snapshot.py +22 -3
- package/scripts/lang_detect.py +12 -3
- package/scripts/local_seek.py +66 -14
- package/scripts/mcp_transport.py +1 -1
- package/scripts/numeric_verify.py +330 -0
- package/scripts/plan.py +25 -4
- package/scripts/pre-commit +2 -2
- package/scripts/rank_signals.py +48 -4
- package/scripts/ranking_eval.py +23 -1
- package/scripts/regression_p0p1.py +7 -2
- package/scripts/release.py +398 -0
- package/scripts/route.py +24 -3
- package/scripts/route_accuracy_eval.py +191 -0
- package/scripts/route_combo.py +32 -1
- package/scripts/route_domains.py +258 -5
- package/scripts/route_primary.py +101 -0
- package/scripts/search.py +5 -2
- package/scripts/search_cli.py +111 -7
- package/scripts/search_output.py +73 -1
- package/scripts/search_pipeline.py +9 -2
- package/scripts/search_rank.py +3 -1
- package/scripts/serp_guard.py +11 -0
- package/scripts/snippet_clean.py +60 -0
- package/scripts/social_engines/twitter_engine.py +127 -43
- package/scripts/social_engines/xiaohongshu_engine.py +11 -1
- package/scripts/tfidf_router.py +52 -2
- package/scripts/train.py +15 -0
- package/scripts/url_canon.py +2 -1
- package/scripts/verify_with.py +124 -0
- package/scripts/video_route.py +3 -3
- package/sub-skills/local-search/SKILL.md +3 -2
- package/sub-skills/local-search/bm25.py +89 -8
- package/sub-skills/local-search/config.yaml +12 -0
- package/sub-skills/local-search/parse_maps.yaml +8 -0
- package/sub-skills/local-search/parsers.py +5 -2
- package/sub-skills/local-search/search_v3.py +87 -1
- package/sub-skills/local-search/smart_router.py +1 -1
- package/sub-skills/local-seek/SKILL.md +6 -5
- package/sub-skills/local-seek/scripts/eval_rank.py +1 -1
- package/sub-skills/local-seek/scripts/seek.py +171 -40
- package/sub-skills/local-seek/scripts/seek_rank.py +191 -11
- package/engines/specs/_cisa_kev.yaml +0 -54
- package/engines/specs/_osv.yaml +0 -63
- package/scripts/image_vision/vision_probe +0 -0
|
@@ -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.py
CHANGED
|
@@ -71,7 +71,6 @@ from route_domains import ( # noqa: E402
|
|
|
71
71
|
match_domains,
|
|
72
72
|
match_domain,
|
|
73
73
|
_get_compiled_domains,
|
|
74
|
-
_compile_domain_patterns,
|
|
75
74
|
_social_domain_first,
|
|
76
75
|
_intent_gate,
|
|
77
76
|
_ZH_LANG_GATED_DOMAINS,
|
|
@@ -129,6 +128,7 @@ from route_lang import ( # noqa: E402
|
|
|
129
128
|
_get_registry,
|
|
130
129
|
)
|
|
131
130
|
from paid_policy import insert_hedge
|
|
131
|
+
from route_primary import promote_executable_primary
|
|
132
132
|
from route_combo import ( # noqa: E402
|
|
133
133
|
_expand_local_search,
|
|
134
134
|
_general_fallback,
|
|
@@ -602,6 +602,12 @@ def _route_by_domain(ctx: _RouteCtx, domain: dict[str, Any], secondary: list[dic
|
|
|
602
602
|
engines_combo = insert_hedge(
|
|
603
603
|
engines_combo, domain.get("name", ""), mode, enabled,
|
|
604
604
|
lang=str((features or {}).get("primary_lang") or ""))
|
|
605
|
+
# primary 可执行性:combo 装配早期不看依赖,缺 CLI 的引擎能占住首位。
|
|
606
|
+
# 顺位到第一个路由与执行都判可用的引擎(判据见函数 docstring)。
|
|
607
|
+
# 不传 specs:_specs_snapshot() 在路由路径下恒为空表(只读已加载的
|
|
608
|
+
# engines 模块),传空表会让依赖判据对全部引擎失效。
|
|
609
|
+
engines_combo, _demoted = promote_executable_primary(
|
|
610
|
+
engines_combo, enabled=enabled)
|
|
605
611
|
|
|
606
612
|
return _done(
|
|
607
613
|
engine=engines_combo[0],
|
|
@@ -617,7 +623,9 @@ def _route_by_domain(ctx: _RouteCtx, domain: dict[str, Any], secondary: list[dic
|
|
|
617
623
|
and e not in set(domain.get("engines_combo") or [])]),
|
|
618
624
|
reason=(
|
|
619
625
|
f"{_feature_labels(features)} → 命中域 [{domain.get('name', '?')}]"
|
|
620
|
-
|
|
626
|
+
# 只有真正进入 combo 的 TF-IDF 推荐才写进 reason:落选(被
|
|
627
|
+
# 否决/预算/域规则挡下)的候选若照写,排查会指向一个从未执行的源。
|
|
628
|
+
+ (f" [TF-IDF→{tfidf_best}]" if tfidf_best and tfidf_best in engines_combo else "")
|
|
621
629
|
+ (" [TF-IDF覆写catch-all]" if is_catch_all and tfidf_best and tfidf_best_score > TFIDF_STRONG_SCORE and tfidf_best in engines_combo else "")
|
|
622
630
|
+ (f" [boost={engines_boost}]" if engines_boost else "")
|
|
623
631
|
+ f" → {_engine_display(engines_combo[0])}"
|
|
@@ -693,6 +701,8 @@ def _route_by_tfidf(ctx: _RouteCtx) -> dict[str, Any]:
|
|
|
693
701
|
# D4:统一熔断统一处理(TF-IDF 注入/语言追加可能绕过 _get_engines_combo)
|
|
694
702
|
engines_combo = breaker_filter(engines_combo, enabled, features=features,
|
|
695
703
|
query=query)
|
|
704
|
+
engines_combo, _demoted = promote_executable_primary(
|
|
705
|
+
engines_combo, enabled=enabled)
|
|
696
706
|
if mode == "fast":
|
|
697
707
|
parallel = False
|
|
698
708
|
else:
|
|
@@ -756,6 +766,8 @@ def _route_by_fallback(ctx: _RouteCtx) -> dict[str, Any]:
|
|
|
756
766
|
# D4:统一熔断统一处理(保底组合可能含熔断引擎)。
|
|
757
767
|
# 兜底次序与本分支的语义一致:通用保底路径只认 anysearch。
|
|
758
768
|
fallback_combo = breaker_filter(fallback_combo, enabled, empty=("anysearch",))
|
|
769
|
+
fallback_combo, _demoted = promote_executable_primary(
|
|
770
|
+
fallback_combo, enabled=enabled)
|
|
759
771
|
|
|
760
772
|
low = tfidf_scores and all(s[1] < TFIDF_MIN_SCORE for s in tfidf_scores)
|
|
761
773
|
reason = (
|
|
@@ -896,9 +908,18 @@ def route_query(query: str, engine_override: str = "auto",
|
|
|
896
908
|
# 选源四道门(社交信号 / 分数地板 / 语言可达 / 死源地板)
|
|
897
909
|
# 见 select_tfidf_best docstring
|
|
898
910
|
_semantic_route = sys.modules[__name__].semantic_route
|
|
911
|
+
# 域规则否决:零实域命中时,被 unless 否决的域其引擎不得被
|
|
912
|
+
# TF-IDF 按词面分复活(判据见 route_domains.vetoes_apply)。
|
|
913
|
+
_vetoed: set[str] = set()
|
|
914
|
+
if not hard_domain:
|
|
915
|
+
try:
|
|
916
|
+
from route_primary import domain_vetoed_engines
|
|
917
|
+
_vetoed = domain_vetoed_engines(query, domains_cfg)
|
|
918
|
+
except Exception:
|
|
919
|
+
_vetoed = set()
|
|
899
920
|
tfidf_best, tfidf_best_score, tfidf_scores = select_tfidf_best(
|
|
900
921
|
query, features, _specs_snapshot(), _semantic_route,
|
|
901
|
-
min_score=TFIDF_MIN_SCORE, enabled=enabled)
|
|
922
|
+
min_score=TFIDF_MIN_SCORE, enabled=enabled, vetoed=_vetoed)
|
|
902
923
|
except ImportError:
|
|
903
924
|
pass
|
|
904
925
|
except Exception as e:
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""route_accuracy_eval.py — 真实查询分布上的路由回归与分布视图(离线,不联网)。
|
|
3
|
+
|
|
4
|
+
## 与既有门的关系
|
|
5
|
+
|
|
6
|
+
- `test_routing_snapshot`:判 201 条语料的 `domain+kind` **不漂移**(回归门);
|
|
7
|
+
- `test_route_accuracy_labeled`:判 13 条人工标注的**意图对不对**(准确率门);
|
|
8
|
+
- 本脚本:在 ~500 条真实查询上算**回归一致率与分布视图**(评测门,出数字)。
|
|
9
|
+
|
|
10
|
+
三者互补:快照防回归,人工集判意图,本脚本看真实分布。
|
|
11
|
+
|
|
12
|
+
## 关键定位:回归一致率,不是准确率
|
|
13
|
+
|
|
14
|
+
弱标注的 `expect_domain` 是**历史路由的输出**,不是真值。2026-11-04 实测:
|
|
15
|
+
31 条「路由输出 != 弱标注期望」的失配里,人工复核 20 条,**19 条是弱标注错、
|
|
16
|
+
路由对**。因此本脚本的 `domain_accuracy` 实际含义是「路由输出与历史输出
|
|
17
|
+
的一致率」,**不是「路由决策的正确率」**。
|
|
18
|
+
|
|
19
|
+
正确率由 `test_route_accuracy_labeled`(13 条人工集)承担。本脚本回答的是
|
|
20
|
+
「路由在真实查询分布上稳不稳、覆没覆盖到」。
|
|
21
|
+
|
|
22
|
+
## 指标
|
|
23
|
+
|
|
24
|
+
| 指标 | 定义 |
|
|
25
|
+
|---|---|
|
|
26
|
+
| `consistency` | 路由输出的 domain == 历史输出的比例(回归一致率) |
|
|
27
|
+
| `family_consistency` | 路由主源的族 == 历史主源族的比例 |
|
|
28
|
+
| `abstain_rate` | 路由落到 `general_search` / `general` 的比例(过度兜底 = 路由没做事) |
|
|
29
|
+
| `stale_labels` | 期望域已不在 config 的条目数(历史遗留噪声,不计入分母) |
|
|
30
|
+
|
|
31
|
+
## 用法
|
|
32
|
+
|
|
33
|
+
python3 scripts/route_accuracy_eval.py # 全量
|
|
34
|
+
python3 scripts/route_accuracy_eval.py --evidence badcase
|
|
35
|
+
python3 scripts/route_accuracy_eval.py --json
|
|
36
|
+
python3 scripts/route_accuracy_eval.py --show-miss 20 # 打印失配样例
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
from __future__ import annotations
|
|
40
|
+
|
|
41
|
+
import argparse
|
|
42
|
+
import json
|
|
43
|
+
import sys
|
|
44
|
+
from collections import Counter, defaultdict
|
|
45
|
+
from pathlib import Path
|
|
46
|
+
from typing import Any
|
|
47
|
+
|
|
48
|
+
ROOT = Path(__file__).resolve().parent.parent
|
|
49
|
+
SCRIPTS = ROOT / "scripts"
|
|
50
|
+
sys.path.insert(0, str(SCRIPTS))
|
|
51
|
+
|
|
52
|
+
LABELS = ROOT / "tests" / "golden" / "route_labeled.jsonl"
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _load_labels(evidence: str | None = None) -> list[dict[str, Any]]:
|
|
56
|
+
if not LABELS.is_file():
|
|
57
|
+
return []
|
|
58
|
+
out = []
|
|
59
|
+
for line in LABELS.read_text(encoding="utf-8").splitlines():
|
|
60
|
+
if not line.strip():
|
|
61
|
+
continue
|
|
62
|
+
d = json.loads(line)
|
|
63
|
+
if evidence and d.get("evidence") != evidence:
|
|
64
|
+
continue
|
|
65
|
+
out.append(d)
|
|
66
|
+
return out
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def evaluate(evidence: str | None = None, show_miss: int = 0) -> dict[str, Any]:
|
|
70
|
+
from route import route_query
|
|
71
|
+
from engine_families import family_of
|
|
72
|
+
from config import get_domains
|
|
73
|
+
|
|
74
|
+
labels = _load_labels(evidence)
|
|
75
|
+
if not labels:
|
|
76
|
+
return {"error": "标注集为空"}
|
|
77
|
+
|
|
78
|
+
# 期望域已不在 config 的条目是**历史遗留噪声**(如 general / general_search
|
|
79
|
+
# 两个域已被合并/改名),不是路由错误——单独归类,不计入准确率分母。
|
|
80
|
+
live_domains = {d.get("name") for d in get_domains()}
|
|
81
|
+
|
|
82
|
+
total = 0
|
|
83
|
+
domain_hit = 0
|
|
84
|
+
family_total = 0
|
|
85
|
+
family_hit = 0
|
|
86
|
+
abstain = 0
|
|
87
|
+
stale = 0
|
|
88
|
+
misses: list[dict[str, Any]] = []
|
|
89
|
+
by_domain: dict[str, dict[str, int]] = defaultdict(lambda: {"n": 0, "hit": 0})
|
|
90
|
+
|
|
91
|
+
for e in labels:
|
|
92
|
+
q = e["query"]
|
|
93
|
+
if e.get("expect_domain") not in live_domains:
|
|
94
|
+
stale += 1
|
|
95
|
+
continue
|
|
96
|
+
try:
|
|
97
|
+
r = route_query(q, mode="auto", depth="fast")
|
|
98
|
+
except Exception:
|
|
99
|
+
continue
|
|
100
|
+
total += 1
|
|
101
|
+
got_dom = r.get("domain")
|
|
102
|
+
got_eng = r.get("engine") or ""
|
|
103
|
+
got_fam = family_of(got_eng)
|
|
104
|
+
want_dom = e.get("expect_domain")
|
|
105
|
+
want_fam = e.get("expect_family")
|
|
106
|
+
|
|
107
|
+
hit = got_dom == want_dom
|
|
108
|
+
domain_hit += hit
|
|
109
|
+
by_domain[want_dom]["n"] += 1
|
|
110
|
+
by_domain[want_dom]["hit"] += hit
|
|
111
|
+
|
|
112
|
+
if want_fam:
|
|
113
|
+
family_total += 1
|
|
114
|
+
if got_eng == want_fam or got_fam == want_fam:
|
|
115
|
+
family_hit += 1
|
|
116
|
+
|
|
117
|
+
if got_dom in ("general_search", "general"):
|
|
118
|
+
abstain += 1
|
|
119
|
+
|
|
120
|
+
if not hit and len(misses) < max(show_miss, 200):
|
|
121
|
+
misses.append({
|
|
122
|
+
"query": q, "want": want_dom, "got": got_dom,
|
|
123
|
+
"engine": got_eng, "family": got_fam,
|
|
124
|
+
"evidence": e.get("evidence"),
|
|
125
|
+
"quality": e.get("quality"),
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
result: dict[str, Any] = {
|
|
129
|
+
"total": total,
|
|
130
|
+
"stale_labels": stale,
|
|
131
|
+
"domain_accuracy": round(domain_hit / total, 4) if total else 0.0,
|
|
132
|
+
"family_accuracy": round(family_hit / family_total, 4) if family_total else None,
|
|
133
|
+
"family_total": family_total,
|
|
134
|
+
"abstain_rate": round(abstain / total, 4) if total else 0.0,
|
|
135
|
+
"domain_hit": domain_hit,
|
|
136
|
+
"abstain": abstain,
|
|
137
|
+
"by_domain": {k: {"n": v["n"], "hit": v["hit"],
|
|
138
|
+
"acc": round(v["hit"] / v["n"], 3)}
|
|
139
|
+
for k, v in sorted(by_domain.items(),
|
|
140
|
+
key=lambda kv: -kv[1]["n"])},
|
|
141
|
+
}
|
|
142
|
+
if show_miss:
|
|
143
|
+
result["misses"] = misses[:show_miss]
|
|
144
|
+
return result
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def _print_text(r: dict[str, Any]) -> None:
|
|
148
|
+
if r.get("error"):
|
|
149
|
+
print(f"[route_accuracy] {r['error']}")
|
|
150
|
+
return
|
|
151
|
+
print(f"[route_accuracy] 样本 {r['total']} 条"
|
|
152
|
+
+ (f"(另有 {r['stale_labels']} 条期望域已不存在,不计入)"
|
|
153
|
+
if r.get("stale_labels") else ""))
|
|
154
|
+
print(f" domain_accuracy = {r['domain_accuracy']:.1%}"
|
|
155
|
+
f"({r['domain_hit']}/{r['total']})")
|
|
156
|
+
if r["family_accuracy"] is not None:
|
|
157
|
+
print(f" family_accuracy = {r['family_accuracy']:.1%}"
|
|
158
|
+
f"({r['family_total']} 条有期望族)")
|
|
159
|
+
print(f" abstain_rate = {r['abstain_rate']:.1%}"
|
|
160
|
+
f"({r['abstain']} 条落到 general)")
|
|
161
|
+
print(" 域分布(样本数 / 命中 / 准确率):")
|
|
162
|
+
for dom, v in list(r["by_domain"].items())[:15]:
|
|
163
|
+
print(f" {dom:24} {v['n']:4} / {v['hit']:4} / {v['acc']:.1%}")
|
|
164
|
+
if r.get("misses"):
|
|
165
|
+
print(f" 失配样例(前 {len(r['misses'])} 条):")
|
|
166
|
+
for m in r["misses"][:20]:
|
|
167
|
+
print(f" {m['query'][:34]!r:38} want={m['want']:20} "
|
|
168
|
+
f"got={m['got']:20} ev={m['evidence']}")
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def main() -> int:
|
|
172
|
+
ap = argparse.ArgumentParser(description="路由准确率评测(离线)")
|
|
173
|
+
ap.add_argument("--evidence", default=None,
|
|
174
|
+
choices=["badcase", "usage_error", "usage_ok"])
|
|
175
|
+
ap.add_argument("--json", action="store_true", dest="json_output")
|
|
176
|
+
ap.add_argument("--show-miss", type=int, default=0)
|
|
177
|
+
args = ap.parse_args()
|
|
178
|
+
|
|
179
|
+
r = evaluate(args.evidence, args.show_miss)
|
|
180
|
+
if args.json_output:
|
|
181
|
+
# 走 cli_io.dumps(紧凑 JSON):CLI stdout 的既有契约,门禁
|
|
182
|
+
# tests/test_context_budget.py::TestStdoutJsonIsCompact 会拦缩进输出。
|
|
183
|
+
from cli_io import dumps
|
|
184
|
+
print(dumps(r))
|
|
185
|
+
else:
|
|
186
|
+
_print_text(r)
|
|
187
|
+
return 0
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
if __name__ == "__main__":
|
|
191
|
+
raise SystemExit(main())
|