argo-search 2.9.9 → 2.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.en.md +39 -22
  2. package/README.es.md +39 -22
  3. package/README.ja.md +38 -21
  4. package/README.ko.md +38 -21
  5. package/README.md +41 -22
  6. package/SKILL.md +13 -12
  7. package/backends/domain_profiles.json +76 -0
  8. package/backends/engine_registry.yaml +163 -7
  9. package/backends/quota_profiles.json +122 -2
  10. package/backends/source_types_cn.json +9 -0
  11. package/bin/argo +22 -1
  12. package/bin/argo.js +3 -3
  13. package/config.yaml +150 -30
  14. package/docs/ARGO_INTRO.md +4 -4
  15. package/docs/ENGINE_CATALOG.md +68 -48
  16. package/docs/MCP_SETUP.md +1 -1
  17. package/docs/RELEASE_NOTES_v2.10.0.md +85 -0
  18. package/docs/RELEASE_NOTES_v2.10.1.md +57 -0
  19. package/docs/RELEASE_NOTES_v2.9.8.md +1 -1
  20. package/docs//344/270/272/344/273/200/344/271/210/351/200/211/346/213/251argo.md +9 -9
  21. package/engines/_template_http.yaml +2 -0
  22. package/engines/specs/clawhub.yaml +16 -15
  23. package/engines/specs/deepseek1024.yaml +46 -0
  24. package/engines/specs/dsh_hub.yaml +44 -0
  25. package/engines/specs/dshopen.yaml +32 -0
  26. package/engines/specs/explainx.yaml +32 -0
  27. package/engines/specs/gbfs_nyc.yaml +6 -1
  28. package/engines/specs/metaso_doc.yaml +49 -0
  29. package/engines/specs/metaso_image.yaml +65 -0
  30. package/engines/specs/metaso_podcast.yaml +60 -0
  31. package/engines/specs/metaso_scholar.yaml +57 -0
  32. package/engines/specs/metaso_video.yaml +62 -0
  33. package/engines/specs/ncpssd.yaml +44 -0
  34. package/engines/specs/sciverse.yaml +73 -0
  35. package/engines/specs/skills_sh.yaml +32 -0
  36. package/engines/specs/skillsmp.yaml +18 -16
  37. package/package.json +4 -2
  38. package/packages/dsh-plugin/README.md +3 -2
  39. package/packages/dsh-plugin/package.json +1 -1
  40. package/packages/dsh-plugin/test/size-gate.test.js +113 -0
  41. package/scripts/adaptive.py +41 -14
  42. package/scripts/article.py +6 -1
  43. package/scripts/article_meta.py +151 -2
  44. package/scripts/bench_general_pool.py +145 -0
  45. package/scripts/candidate_envelope.py +45 -4
  46. package/scripts/charset_decode.py +127 -0
  47. package/scripts/ci_drift_gate.py +47 -24
  48. package/scripts/crawl.py +240 -74
  49. package/scripts/crawl_frontier.py +217 -0
  50. package/scripts/crawl_policy.py +174 -0
  51. package/scripts/engine_dispatch.py +23 -18
  52. package/scripts/engine_failure.py +15 -0
  53. package/scripts/engine_status.py +12 -5
  54. package/scripts/engine_validate.py +8 -0
  55. package/scripts/engines.py +15 -0
  56. package/scripts/engines_base.py +43 -15
  57. package/scripts/engines_builders.py +14 -0
  58. package/scripts/engines_builders_data.py +10 -3
  59. package/scripts/engines_builders_dsh.py +330 -0
  60. package/scripts/engines_builders_skill.py +314 -0
  61. package/scripts/evidence.py +26 -5
  62. package/scripts/fetch_v3.py +37 -5
  63. package/scripts/gen_engine_catalog.py +218 -2
  64. package/scripts/general_pool.py +162 -0
  65. package/scripts/http_client.py +38 -42
  66. package/scripts/image_ops.py +4 -0
  67. package/scripts/install.ps1 +47 -19
  68. package/scripts/install.sh +45 -20
  69. package/scripts/local_seek.py +53 -11
  70. package/scripts/matrix_search_eval.py +17 -1
  71. package/scripts/mcp_transport.py +1 -1
  72. package/scripts/ncpssd_bridge.py +123 -0
  73. package/scripts/paid_policy.py +109 -13
  74. package/scripts/pre-commit +19 -4
  75. package/scripts/query_signals.py +156 -3
  76. package/scripts/redskill/redskill_engine.py +29 -2
  77. package/scripts/release.py +398 -0
  78. package/scripts/release_check.py +209 -0
  79. package/scripts/retry_policy.py +22 -1
  80. package/scripts/robots_guard.py +26 -0
  81. package/scripts/route.py +11 -8
  82. package/scripts/route_cache.py +6 -0
  83. package/scripts/route_combo.py +37 -59
  84. package/scripts/route_domains.py +22 -3
  85. package/scripts/route_policy.py +6 -0
  86. package/scripts/search.py +13 -3
  87. package/scripts/search_cli.py +49 -0
  88. package/scripts/search_entry.py +9 -0
  89. package/scripts/search_output.py +43 -0
  90. package/scripts/search_pipeline.py +43 -3
  91. package/scripts/search_rank.py +4 -1
  92. package/scripts/serp_guard.py +11 -0
  93. package/scripts/social_engines/bilibili_engine.py +163 -26
  94. package/scripts/social_engines/reddit_engine.py +52 -51
  95. package/scripts/source_selection.py +302 -0
  96. package/scripts/url_canon.py +2 -1
  97. package/scripts/video_fetch.py +303 -0
  98. package/scripts/video_meta.py +225 -0
  99. package/scripts/video_route.py +65 -0
  100. package/scripts/watch.py +123 -0
  101. package/sub-skills/local-seek/scripts/seek.py +19 -4
  102. package/engines/specs/_cisa_kev.yaml +0 -54
  103. package/engines/specs/_osv.yaml +0 -63
  104. package/scripts/local_engines.py +0 -321
@@ -101,23 +101,45 @@ if ($Pin) {
101
101
  }
102
102
 
103
103
  if (-not $SkipPip) {
104
- Write-Host "==> 安装依赖 (PyYAML)…"
105
- & $script:py -m pip install pyyaml
106
- if ($LASTEXITCODE -ne 0) {
107
- & $script:py -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyyaml
108
- }
109
- if ($LASTEXITCODE -ne 0) { Write-Host "[warn] pip 安装 PyYAML 失败,可手动: pip install pyyaml" }
110
- Write-Host "==> 安装可选增强 (curl_cffi: TLS 指纹伪造;rapidfuzz: 去重模糊近重复复核;缺失不影响核心功能)…"
111
- & $script:py -m pip install curl_cffi
112
- if ($LASTEXITCODE -ne 0) {
113
- & $script:py -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple curl_cffi
114
- }
115
- if ($LASTEXITCODE -ne 0) { Write-Host "[warn] pip 安装 curl_cffi 失败(可选依赖)" }
116
- & $script:py -m pip install rapidfuzz
117
- if ($LASTEXITCODE -ne 0) {
118
- & $script:py -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple rapidfuzz
104
+ # 与 install.sh 同一策略:依赖优先装进 $InstallDir\.venv(bin/argo 的
105
+ # 解释器候选链会自动发现它,见 _venv_python)。Windows 的 python.org
106
+ # 安装包通常不受 PEP 668 限制,但 venv 仍优于全局安装:不污染全局
107
+ # site-packages,卸载/升级干净,与 macOS/Linux 行为一致。
108
+ $VenvDir = Join-Path $InstallDir ".venv"
109
+ $VenvPy = Join-Path $VenvDir "Scripts\python.exe"
110
+ & $script:py -m venv $VenvDir 2>$null
111
+ if ($LASTEXITCODE -eq 0 -and (Test-Path $VenvPy)) {
112
+ Write-Host "==> 创建虚拟环境: $VenvDir(依赖装在这里,不碰系统 Python)"
113
+ & $VenvPy -m pip install pyyaml
114
+ if ($LASTEXITCODE -ne 0) {
115
+ & $VenvPy -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyyaml
116
+ }
117
+ if ($LASTEXITCODE -ne 0) { Write-Host "[warn] venv 内 PyYAML 安装失败,可手动: & `"$VenvPy`" -m pip install pyyaml" }
118
+ Write-Host "==> 安装可选增强 (curl_cffi: TLS 指纹伪造;rapidfuzz: 去重模糊近重复复核;缺失不影响核心功能)…"
119
+ & $VenvPy -m pip install curl_cffi
120
+ if ($LASTEXITCODE -ne 0) { Write-Host "[warn] pip 安装 curl_cffi 失败(可选依赖)" }
121
+ & $VenvPy -m pip install rapidfuzz
122
+ if ($LASTEXITCODE -ne 0) { Write-Host "[warn] pip 安装 rapidfuzz 失败(可选依赖,缺失时去重回退纯 minhash)" }
123
+ } else {
124
+ Write-Host "[warn] venv 创建失败,回退系统 pip 安装…"
125
+ Write-Host "==> 安装依赖 (PyYAML)…"
126
+ & $script:py -m pip install pyyaml
127
+ if ($LASTEXITCODE -ne 0) {
128
+ & $script:py -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyyaml
129
+ }
130
+ if ($LASTEXITCODE -ne 0) { Write-Host "[warn] pip 安装 PyYAML 失败,可手动: pip install pyyaml" }
131
+ Write-Host "==> 安装可选增强 (curl_cffi: TLS 指纹伪造;rapidfuzz: 去重模糊近重复复核;缺失不影响核心功能)…"
132
+ & $script:py -m pip install curl_cffi
133
+ if ($LASTEXITCODE -ne 0) {
134
+ & $script:py -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple curl_cffi
135
+ }
136
+ if ($LASTEXITCODE -ne 0) { Write-Host "[warn] pip 安装 curl_cffi 失败(可选依赖)" }
137
+ & $script:py -m pip install rapidfuzz
138
+ if ($LASTEXITCODE -ne 0) {
139
+ & $script:py -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple rapidfuzz
140
+ }
141
+ if ($LASTEXITCODE -ne 0) { Write-Host "[warn] pip 安装 rapidfuzz 失败(可选依赖,缺失时去重回退纯 minhash)" }
119
142
  }
120
- if ($LASTEXITCODE -ne 0) { Write-Host "[warn] pip 安装 rapidfuzz 失败(可选依赖,缺失时去重回退纯 minhash)" }
121
143
  }
122
144
 
123
145
  if ($LinkTargets.Count -gt 0 -or (Test-Path (Join-Path $InstallDir "installs.local.yaml"))) {
@@ -135,9 +157,13 @@ Write-Host ""
135
157
  Write-Host "==> 安装完成"
136
158
  Write-Host ""
137
159
  $pyLabel = $script:py -join " "
160
+ # 文档里的解释器:venv 在就用它(与 bin/argo 的选择一致,避免「装好了但
161
+ # 示例跑不起来」——回退安装时系统 python 可能没有 PyYAML)。
162
+ $VenvDocPy = Join-Path $InstallDir ".venv\Scripts\python.exe"
163
+ if (Test-Path $VenvDocPy) { $pyLabel = "& `"$VenvDocPy`"" }
138
164
  Write-Host "快速验证:"
139
- Write-Host " & $pyLabel $InstallDir\scripts\search.py ""Python asyncio"" --json"
140
- Write-Host " & $pyLabel $InstallDir\scripts\search.py --list-engines"
165
+ Write-Host " $pyLabel $InstallDir\scripts\search.py ""Python asyncio"" --json"
166
+ Write-Host " $pyLabel $InstallDir\scripts\search.py --list-engines"
141
167
  Write-Host ""
142
168
  Write-Host "启动 MCP(给 Claude / Kimi / Cursor 等用):"
143
169
  Write-Host " & $pyLabel $InstallDir\scripts\mcp_server.py"
@@ -146,7 +172,9 @@ Write-Host "或用 npx(需 Node.js 18+,推荐,不依赖 npm 发版):"
146
172
  Write-Host " npx -y github:taxueseek/argo"
147
173
  Write-Host ""
148
174
  Write-Host "客户端 MCP 配置示例(command 用解释器绝对路径:GUI 宿主的子进程 PATH 常缺 python):"
149
- $pythonExe = (Get-Command $script:py[0] -ErrorAction SilentlyContinue).Source
175
+ $pythonExe = $null
176
+ if (Test-Path $VenvDocPy) { $pythonExe = $VenvDocPy }
177
+ if (-not $pythonExe) { $pythonExe = (Get-Command $script:py[0] -ErrorAction SilentlyContinue).Source }
150
178
  if (-not $pythonExe) { $pythonExe = $script:py[0] }
151
179
  Write-Host @"
152
180
  {
@@ -131,20 +131,38 @@ if [[ -n "$PIN" ]]; then
131
131
  fi
132
132
 
133
133
  if [[ "$SKIP_PIP" != "1" ]]; then
134
- echo "==> 安装依赖 (PyYAML)…"
135
- python3 -m pip install --user -q pyyaml 2>/dev/null \
136
- || python3 -m pip install -q pyyaml 2>/dev/null \
137
- || python3 -m pip install --user -q -i https://pypi.tuna.tsinghua.edu.cn/simple pyyaml 2>/dev/null \
138
- || echo "[warn] pip 安装 PyYAML 失败,可手动: pip install pyyaml"
139
- echo "==> 安装可选增强 (curl_cffi: TLS 指纹伪造;rapidfuzz: 去重模糊近重复复核;缺失不影响核心功能)…"
140
- python3 -m pip install --user -q curl_cffi 2>/dev/null \
141
- || python3 -m pip install -q curl_cffi 2>/dev/null \
142
- || python3 -m pip install --user -q -i https://pypi.tuna.tsinghua.edu.cn/simple curl_cffi 2>/dev/null \
143
- || echo "[warn] pip 安装 curl_cffi 失败(可选依赖)。需要反爬 TLS 指纹伪造时手动: pip install curl_cffi"
144
- python3 -m pip install --user -q rapidfuzz 2>/dev/null \
145
- || python3 -m pip install -q rapidfuzz 2>/dev/null \
146
- || python3 -m pip install --user -q -i https://pypi.tuna.tsinghua.edu.cn/simple rapidfuzz 2>/dev/null \
147
- || echo "[warn] pip 安装 rapidfuzz 失败(可选依赖)。缺失时去重回退纯 minhash,需要模糊近重复复核时手动: pip install rapidfuzz"
134
+ # 依赖优先装进 $INSTALL_DIR/.venv(bin/argo 的解释器候选链会自动发现它,
135
+ # 见 _venv_python)。为什么要 venv:PEP 668(Homebrew、Debian 12+、
136
+ # Ubuntu 23.04+)把系统 Python 标记为 externally-managed,`pip install
137
+ # --user` 与全局安装都会被拒——旧的三段回落(--user → 全局 → 清华镜像)
138
+ # 在这类机器上三连败,装完没有 PyYAML,第一次 `argo search` 就倒在
139
+ # ModuleNotFoundError(2026-10-23 审计实测)。venv 是解释器自己管的目录,
140
+ # 不受该限制,也不污染用户 site-packages(user-site 遮蔽 Homebrew 主树
141
+ # 的历史风险一并消失)。
142
+ VENV_DIR="$INSTALL_DIR/.venv"
143
+ if python3 -m venv "$VENV_DIR" 2>/dev/null; then
144
+ echo "==> 创建虚拟环境: ${VENV_DIR}(依赖装在这里,不碰系统 Python)"
145
+ "$VENV_DIR/bin/pip" install -q pyyaml \
146
+ || echo "[warn] venv 内 PyYAML 安装失败,可手动: $VENV_DIR/bin/pip install pyyaml"
147
+ echo "==> 安装可选增强 (curl_cffi: TLS 指纹伪造;rapidfuzz: 去重模糊近重复复核;缺失不影响核心功能)…"
148
+ "$VENV_DIR/bin/pip" install -q curl_cffi rapidfuzz 2>/dev/null \
149
+ || echo "[warn] 可选增强安装失败(不影响核心功能);需要时: $VENV_DIR/bin/pip install curl_cffi rapidfuzz"
150
+ else
151
+ echo "[warn] venv 创建失败(Debian/Ubuntu 需先 sudo apt install python3-venv),回退系统 pip 安装…"
152
+ python3 -m pip install --user -q pyyaml 2>/dev/null \
153
+ || python3 -m pip install -q pyyaml 2>/dev/null \
154
+ || python3 -m pip install --user -q -i https://pypi.tuna.tsinghua.edu.cn/simple pyyaml 2>/dev/null \
155
+ || echo "[warn] pip 安装 PyYAML 失败,可手动: pip install pyyaml"
156
+ echo "==> 安装可选增强 (curl_cffi: TLS 指纹伪造;rapidfuzz: 去重模糊近重复复核;缺失不影响核心功能)…"
157
+ python3 -m pip install --user -q curl_cffi 2>/dev/null \
158
+ || python3 -m pip install -q curl_cffi 2>/dev/null \
159
+ || python3 -m pip install --user -q -i https://pypi.tuna.tsinghua.edu.cn/simple curl_cffi 2>/dev/null \
160
+ || echo "[warn] pip 安装 curl_cffi 失败(可选依赖)。需要反爬 TLS 指纹伪造时手动: pip install curl_cffi"
161
+ python3 -m pip install --user -q rapidfuzz 2>/dev/null \
162
+ || python3 -m pip install -q rapidfuzz 2>/dev/null \
163
+ || python3 -m pip install --user -q -i https://pypi.tuna.tsinghua.edu.cn/simple rapidfuzz 2>/dev/null \
164
+ || echo "[warn] pip 安装 rapidfuzz 失败(可选依赖)。缺失时去重回退纯 minhash,需要模糊近重复复核时手动: pip install rapidfuzz"
165
+ fi
148
166
  fi
149
167
 
150
168
  # ── pre-commit 快门禁 hook(2026-10-16 流程洞实证后新增) ──────────────────
@@ -189,15 +207,22 @@ if [[ ${#LINK_ARGS[@]} -gt 0 ]] || [[ -n "${ARGO_LINK_TARGETS:-}" ]] || [[ -f "$
189
207
  }
190
208
  fi
191
209
 
210
+ # 文档里的解释器:venv 在就用它(与 bin/argo 的选择一致,避免「装好了但
211
+ # 示例跑不起来」——系统 python3 可能没有 PyYAML)。
212
+ RUN_PY="python3"
213
+ if [[ -x "$INSTALL_DIR/.venv/bin/python" ]]; then
214
+ RUN_PY="$INSTALL_DIR/.venv/bin/python"
215
+ fi
216
+
192
217
  echo ""
193
218
  echo "==> 安装完成"
194
219
  echo ""
195
220
  echo "快速验证:"
196
- echo " python3 $INSTALL_DIR/scripts/search.py \"Python asyncio\" --json"
197
- echo " python3 $INSTALL_DIR/scripts/search.py --list-engines"
221
+ echo " $RUN_PY $INSTALL_DIR/scripts/search.py \"Python asyncio\" --json"
222
+ echo " $RUN_PY $INSTALL_DIR/scripts/search.py --list-engines"
198
223
  echo ""
199
224
  echo "启动 MCP(给 Claude / Kimi / Cursor 等用):"
200
- echo " python3 $INSTALL_DIR/scripts/mcp_server.py"
225
+ echo " $RUN_PY $INSTALL_DIR/scripts/mcp_server.py"
201
226
  echo ""
202
227
  echo "或用 npx(需 Node.js 18+):"
203
228
  echo " npx -y github:taxueseek/argo"
@@ -207,7 +232,7 @@ cat <<EOF
207
232
  {
208
233
  "mcpServers": {
209
234
  "argo": {
210
- "command": "python3",
235
+ "command": "$RUN_PY",
211
236
  "args": ["$INSTALL_DIR/scripts/mcp_server.py"]
212
237
  }
213
238
  }
@@ -215,7 +240,7 @@ cat <<EOF
215
240
  EOF
216
241
  echo ""
217
242
  echo "可选:把 Skill 挂到本机 Agent 目录(不复制代码):"
218
- echo " python3 $INSTALL_DIR/scripts/link_source.py --to ~/.claude/skills/argo"
219
- echo " python3 $INSTALL_DIR/scripts/link_source.py --to ~/.agents/skills/argo"
243
+ echo " $RUN_PY $INSTALL_DIR/scripts/link_source.py --to ~/.claude/skills/argo"
244
+ echo " $RUN_PY $INSTALL_DIR/scripts/link_source.py --to ~/.agents/skills/argo"
220
245
  echo ""
221
246
  echo "文档: https://github.com/taxueseek/argo"
@@ -31,6 +31,26 @@ from typing import Any
31
31
  # 本地命中是尾部增强项,不是主结果,它的等待不配与搜索引擎同等。
32
32
  _LOCAL_SEEK_TIMEOUT_S = 3.0
33
33
 
34
+ # 搜索期告警(issue #34 第 4/7 条):--json 模式下 stderr 会被调用方
35
+ # 2>&1 合并,任何中文告警行都会破坏 JSON 解析。告警统一进这个列表,
36
+ # search.py 组装完响应后 drain 并作为 warnings[] 字段随 JSON 返回;
37
+ # 非 --json 调用保持写 stderr 的老行为(echo=True)。
38
+ _SEARCH_WARNINGS: list[str] = []
39
+
40
+
41
+ def _note_warning(msg: str, echo: bool = True) -> None:
42
+ """记录一条搜索期告警;echo=True 时同时写 stderr(人读模式)。"""
43
+ _SEARCH_WARNINGS.append(msg)
44
+ if echo:
45
+ sys.stderr.write(msg + "\n")
46
+
47
+
48
+ def drain_search_warnings() -> list[str]:
49
+ """取出并清空搜索期告警(search.py 在响应组装完后合并进 warnings[])。"""
50
+ out = _SEARCH_WARNINGS[:]
51
+ _SEARCH_WARNINGS.clear()
52
+ return out
53
+
34
54
  # 「宽泛根」判定:这些目录**不能**当作本地检索范围。
35
55
  # 跨平台补齐(2026-09-29):/mnt(WSL 挂载根)、/cygdrive(Cygwin)——
36
56
  # 此前是 macOS 视角清单,Windows/WSL 的等价宽根漏网。
@@ -232,13 +252,17 @@ def _local_seek_dir() -> str | None:
232
252
 
233
253
  def _run_local_seek(query: str, max_n: int = 5,
234
254
  search_dir: str | None = None,
235
- warn: bool = True) -> list[dict[str, Any]]:
255
+ warn: bool = True, echo: bool = True) -> list[dict[str, Any]]:
236
256
  """本机文件命中(include-local 用):进程内调 seek.run_query,JSON 并入。
237
257
 
238
258
  fast/budget 模式下由 super_search 自动调用(_resolve_include_local),
239
259
  auto/deep 需显式 --include-local / MCP include_local。评分与
240
260
  MCP argo_local_search 同口径(0.9 精确 / 0.7 扩展)。
241
261
  进程内失败回退子进程形态(_seek_query_subprocess),能力不回退。
262
+
263
+ echo=False 时告警不写 stderr,只进 drain_search_warnings()——`--json`
264
+ 模式的调用方把 2>&1 合并成管道时,stderr 上的中文行会破坏 JSON 解析
265
+ (issue #34 第 7 条),告警改为结构化字段随响应返回。
242
266
  """
243
267
  target = search_dir or _local_seek_dir()
244
268
  if not target:
@@ -246,15 +270,16 @@ def _run_local_seek(query: str, max_n: int = 5,
246
270
  # 「跳过」与「查了没有」在返回值上都是空列表,但含义完全不同——
247
271
  # 静默跳过会让用户以为本地没匹配,而事实是根本没查。返回一个
248
272
  # 占位「结果」又会污染 results(它只是个说明,不是命中),所以
249
- # 说明走 stderr:与 CLI 既有的 include-local 异常提示同一条通道。
273
+ # 说明走告警通道(stderr + 响应的 warnings[])。
250
274
  # 只在**显式开启**时提示(warn=False 是 fast/budget 的自动路径):
251
275
  # 自动路径在 home 等宽根下每次 search 都会打印,Agent 会把它当成
252
276
  # 输出的一部分,属于噪音而非归因。
253
277
  if warn:
254
- sys.stderr.write(
278
+ _note_warning(
255
279
  " [include-local] 当前目录不适合本地检索(home / 根目录过宽,或位于 argo "
256
280
  "自身安装树内——只会命中自身源码),已跳过;"
257
- "要搜本机文件请 cd 到目标目录后重试,或用 local-seek 的 seek.py --path <目录>\n")
281
+ "要搜本机文件请 cd 到目标目录后重试,或用 local-seek 的 seek.py --path <目录>",
282
+ echo)
258
283
  return []
259
284
 
260
285
  # 缓存:同 query+target 在 TTL 内直接命中,避免重复冷启动 seek.py 子进程。
@@ -279,6 +304,13 @@ def _run_local_seek(query: str, max_n: int = 5,
279
304
  from seek_locator import resolve_seek_py
280
305
  seek_py = resolve_seek_py()
281
306
  if not seek_py or not os.path.isfile(seek_py):
307
+ # issue #34 第 4 条:显式 --include-local 时 seek.py 找不到,此前静默
308
+ # 返回空列表,看起来与「本地没有匹配」一模一样。真正能定位的线索
309
+ # (装了 local-seek 子技能 / 设 ARGO_LOCAL_SEEK_PATH)必须说出来。
310
+ if warn:
311
+ _note_warning(
312
+ " [include-local] 未找到 local-seek 的 seek.py(装 local-seek 子技能,"
313
+ "或设 ARGO_LOCAL_SEEK_PATH 指向 seek.py);本机文件检索未执行", echo)
282
314
  return []
283
315
 
284
316
  # H2(2026-09-29):进程内直调 seek.run_query——省掉子进程解释器启动
@@ -289,12 +321,13 @@ def _run_local_seek(query: str, max_n: int = 5,
289
321
  payload = None
290
322
  try:
291
323
  payload = seek_query_payload(query, target, max_n,
292
- time_budget=_LOCAL_SEEK_TIMEOUT_S)
324
+ time_budget=_LOCAL_SEEK_TIMEOUT_S,
325
+ warn=warn, echo=echo)
293
326
  except Exception:
294
327
  payload = None
295
328
  if payload is None:
296
329
  payload = _seek_query_subprocess(seek_py, query, target, max_n)
297
- if payload is None:
330
+ if payload is None or payload.get("_error"):
298
331
  return []
299
332
  out = _payload_to_hits(payload, max_n, cache_key)
300
333
  _seek_disk_cache_put(cache_key, out) # H3:写穿到落盘层
@@ -319,7 +352,8 @@ def _load_seek_module(seek_py: str):
319
352
 
320
353
 
321
354
  def seek_query_payload(query: str, target: str, max_n: int,
322
- exact: bool = False, time_budget: float | None = None
355
+ exact: bool = False, time_budget: float | None = None,
356
+ warn: bool = False, echo: bool = True
323
357
  ) -> dict[str, Any] | None:
324
358
  """H2 公共入口:进程内调 seek.run_query 取 JSON payload。
325
359
 
@@ -339,11 +373,19 @@ def seek_query_payload(query: str, target: str, max_n: int,
339
373
  argv.append("--exact")
340
374
  text, rc = mod.run_query(argv, time_budget=time_budget)
341
375
  if rc != 0:
342
- # rc=1 是「搜了没命中」,不是「真失败」——区分两者避免子进程回退
343
- # 把同一搜索再跑一遍(实测 787ms vs 命中路径 12ms,双跑税 ~775ms)。
344
- # 无命中返回空结果(不回退);真失败返回 None(调用方回退子进程)。
345
- if rc == 1 and not text.strip():
376
+ # rc=1 有两类:
377
+ # 1) 「未找到匹配」:seek.run_query 返回 "local-seek: 未找到匹配(...)"。
378
+ # 这是正常零命中,不是进程内异常——返回空结果避免子进程回退把同一搜索
379
+ # 再跑一遍(消除双跑税),并让 0 命中写入缓存。
380
+ # 2) 确定性环境/参数错误(如 Windows 缺 rg/grep、目录不存在):
381
+ # 子进程重跑结果完全一样;转为结构化告警并停止无意义回退(issue #34.4)。
382
+ stripped = text.strip()
383
+ if rc == 1 and (not stripped or "未找到匹配" in stripped):
346
384
  return {"results": [], "total": 0}
385
+ if rc == 1 and stripped.startswith("local-seek:"):
386
+ if warn:
387
+ _note_warning(f" [include-local] {stripped}", echo)
388
+ return {"results": [], "total": 0, "_error": stripped}
347
389
  return None
348
390
  if not text.strip():
349
391
  return None
@@ -219,6 +219,12 @@ ROUTE_MATRIX: list[dict[str, Any]] = [
219
219
  {"id": "R_ko_film", "q": "기생충 영화 감독", "lang": "ko",
220
220
  "domain": "film_search", "primary": "imdb", "scenario": "film", "soft": True},
221
221
 
222
+ # ── 视频(2026-10-27 新增域)──
223
+ # 显式「视频」意图必须落到 video 域;泛化的「视频生成模型」由
224
+ # chinese_tech_deep 接管(见 test_domain_rule_schema 的反例表)。
225
+ {"id": "R_zh_video_recipe", "q": "红烧肉 做法 视频", "lang": "zh",
226
+ "domain": "video", "primary": "bilibili", "scenario": "video"},
227
+
222
228
  # ── 体育 ──
223
229
  {"id": "R_zh_sports", "q": "梅西 俱乐部", "lang": "zh",
224
230
  "domain": "sports_search", "primary": "thesportsdb", "scenario": "sports"},
@@ -375,8 +381,17 @@ ROUTE_MATRIX: list[dict[str, Any]] = [
375
381
  # 事故:英文技术无域查询 fast 保底为 anysearch 单引擎,首引擎上游波动
376
382
  # 返回高计数垃圾时早停吞掉次引擎(execution 层守卫见 search.py
377
383
  # _query_coverage_ok;此处钉路由层契约:保底 combo 必含 ≥2 个免费通用源)。
384
+ # 2026-10-26 9f50a12 通用层改实测排序后,兜底 combo 由 anysearch 领跑
385
+ # 换成 yuanbao+tavily_free(隔离 A/B p50 773→489ms)——契约不变,引擎
386
+ # 身份随实测排序走,故候选表跟随扩到当前领跑组合(原表断言的 anysearch/
387
+ # local_bing 在新排序下已不是前三位)。
388
+ # 2026-10-27:覆盖地板 + 语言门落地后,英文通用的领队是 parallel_free
389
+ # (tavily 交付 2 条低于地板、yuanbao 只声明 chinese)。契约仍是「前三位
390
+ # ≥2 个通用源」,候选表继续随实测领队更新。
378
391
  {"id": "R_en_tech_nodomain", "q": "Crawl4AI pruning content filter extraction",
379
- "lang": "en", "domain": "general_search", "primary_any": ["anysearch", "local_bing"],
392
+ "lang": "en", "domain": "general_search",
393
+ "primary_any": ["anysearch", "local_bing", "yuanbao", "tavily_free",
394
+ "parallel_free"],
380
395
  "forbid_cn": True, "scenario": "general"},
381
396
  {"id": "R_en_tech_py", "q": "python asyncio tutorial", "lang": "en",
382
397
  "domain": "english_tech", "primary_any": ["octen", "anysearch", "local_bing"],
@@ -489,6 +504,7 @@ ROUTE_MATRIX: list[dict[str, Any]] = [
489
504
  {"id": "R_semantic_discovery", "q": "discover landscape ecosystem emerging", "lang": "en", "domain": "semantic_discovery", "primary": "exa", "scenario": "tech"},
490
505
  {"id": "R_shopping", "q": "购物 评测 推荐 踩坑", "lang": "zh", "domain": "shopping", "primary": "zhihu", "scenario": "media"},
491
506
  {"id": "R_skill_search", "q": "agent skills 市场 目录", "lang": "en", "domain": "skill_search", "primary": "skillsmp", "scenario": "community"},
507
+ {"id": "R_dsh_plugin", "q": "dsh 插件 记忆", "lang": "zh", "domain": "dsh_plugin_search", "primary": "dshopen", "scenario": "community"}, # DSH 插件目录(与 skill_search 语义不同:插件是 npm 包,技能是 SKILL.md)
492
508
  {"id": "R_species_search", "q": "物种 学名 生物分类 拉丁名", "lang": "zh", "domain": "species_search", "primary": "gbif", "scenario": "academic"},
493
509
  {"id": "R_stackoverflow_search", "q": "stackoverflow 编程问题 代码问题", "lang": "zh", "domain": "stackoverflow_search", "primary": "stackoverflow", "scenario": "code"},
494
510
  {"id": "R_standards", "q": "国家标准 国标 标准号", "lang": "zh", "domain": "standards", "primary": "std_samr", "scenario": "academic"},
@@ -22,7 +22,7 @@ except Exception: # pragma: no cover
22
22
 
23
23
  # 版本来源:与 package.json / SKILL.md 保持一致(发布时统一升版;
24
24
  # tests/test_consistency_gates.py 会四端对账,漂移即红)
25
- ARGO_MCP_VERSION = "2.9.9"
25
+ ARGO_MCP_VERSION = "2.10.1"
26
26
 
27
27
  _response_format = "content-length" # 根据客户端请求自动切换
28
28
 
@@ -0,0 +1,123 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """NCPSSD(国家哲学社会科学文献中心)检索桥 —— 供 argo 的 CLI 引擎调用。
4
+
5
+ 上游 https://www.ncpssd.cn/searchHandler/search 只吃表单 POST(实测:GET 返回 HTML、
6
+ POST 空体+查询串被 WAF 493),argo 的声明式 http 引擎只会发 JSON POST / GET,
7
+ 故用本桥代发表单请求,再把结果转成 argo 认得的 items 结构。
8
+
9
+ 用法:python ncpssd_bridge.py "唯物史观" -n 10
10
+ 输出:stdout 一行 JSON(ASCII 转义,避免 Windows 管道默认 GBK 把中文写坏)。
11
+ """
12
+ from __future__ import annotations
13
+
14
+ import argparse
15
+ import json
16
+ import re
17
+ import urllib.request
18
+ import urllib.parse
19
+
20
+ from net_proxy import open_url # 代理感知出口:不认 network.proxy 的直连在代理环境必挂(issue #13 同类)
21
+
22
+ ENDPOINT = "https://www.ncpssd.cn/searchHandler/search"
23
+ SORT = "synUpdateType|DESC,date|DESC,ik_subject|DESC,id|DESC"
24
+ TAGS = ("IKTE", "IKPYTE", "IKST", "IKET", "IKSE")
25
+ DETAIL = "https://www.ncpssd.cn/Literature/articleinfo?type={tab}&id={ident}"
26
+ HEADERS = {
27
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/131.0",
28
+ "Accept": "application/json, text/javascript, */*; q=0.01",
29
+ "Accept-Language": "zh-CN,zh;q=0.9",
30
+ "X-Requested-With": "XMLHttpRequest",
31
+ "Referer": "https://www.ncpssd.cn/",
32
+ "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
33
+ }
34
+ _TAG_RE = re.compile(r"<[^>]+>")
35
+ _DATE_RE = re.compile(r"(\d{4})-(\d{2})-(\d{2})")
36
+
37
+
38
+ def _clean(value) -> str:
39
+ if value is None:
40
+ return ""
41
+ if isinstance(value, (list, tuple)):
42
+ value = ";".join(str(v) for v in value if v)
43
+ return _TAG_RE.sub("", str(value)).strip()
44
+
45
+
46
+ def _date(value) -> str:
47
+ m = _DATE_RE.match(str(value or ""))
48
+ return m.group(0) if m else ""
49
+
50
+
51
+ def _expression(word: str) -> str:
52
+ return "(" + " OR ".join(f'{tag}="{word}"' for tag in TAGS) + ")"
53
+
54
+
55
+ def fetch(word: str, count: int, timeout: float = 20.0) -> list[dict]:
56
+ body = urllib.parse.urlencode({
57
+ "search": _expression(word),
58
+ "pageNum": "1",
59
+ "pageSize": str(max(1, min(count, 30))),
60
+ "sort": SORT,
61
+ "sType": "0",
62
+ "ajaxKeys": "",
63
+ "customShowCondition": word,
64
+ }).encode("utf-8")
65
+ req = urllib.request.Request(ENDPOINT, data=body, headers=HEADERS, method="POST")
66
+ with open_url(req, timeout=timeout) as resp:
67
+ payload = json.loads(resp.read().decode("utf-8", "replace"))
68
+ rows = ((payload.get("data") or {}).get("rows")) or []
69
+ items: list[dict] = []
70
+ for row in rows[:count]:
71
+ if not isinstance(row, dict):
72
+ continue
73
+ title = _clean(row.get("title")) or _clean(row.get("ik_title"))
74
+ if not title:
75
+ continue
76
+ ident = _clean(row.get("id") or row.get("data_id"))
77
+ tab = _clean(row.get("tab_name")) or "journalArticle"
78
+ detail = DETAIL.format(tab=tab, ident=ident) if ident else ""
79
+ pdf = _clean(row.get("pdfurl"))
80
+ volume = _clean(row.get("volumn"))
81
+ issue = _clean(row.get("num"))
82
+ pages = ""
83
+ if _clean(row.get("beginpage")):
84
+ pages = _clean(row.get("beginpage")) + "-" + _clean(row.get("endpage")) + "页"
85
+ meta = " · ".join(part for part in (
86
+ _clean(row.get("creator")) or _clean(row.get("creator_auto")),
87
+ _clean(row.get("cbw_name")) or _clean(row.get("bookname")),
88
+ "".join(x for x in (_clean(row.get("years")), volume and f"第{volume}卷", issue and f"第{issue}期") if x),
89
+ pages,
90
+ _clean(row.get("type")),
91
+ ) if part)
92
+ abstract = _clean(row.get("remark")) or _clean(row.get("ik_remark"))
93
+ snippet = "|".join(part for part in (
94
+ f"详情 {detail}" if (pdf and detail) else "",
95
+ meta,
96
+ abstract,
97
+ ) if part)
98
+ items.append({
99
+ "title": title,
100
+ "url": pdf or detail,
101
+ "snippet": snippet,
102
+ "published_at": _date(row.get("date")),
103
+ })
104
+ return items
105
+
106
+
107
+ def main(argv=None) -> int:
108
+ parser = argparse.ArgumentParser(description="NCPSSD 检索(argo CLI 桥)")
109
+ parser.add_argument("query")
110
+ parser.add_argument("-n", "--count", type=int, default=10)
111
+ args = parser.parse_args(argv)
112
+ try:
113
+ items = fetch(args.query.strip(), args.count)
114
+ except Exception as exc: # 上游异常也要给 argo 一个可解析的空结果
115
+ print(json.dumps({"items": [], "error": f"{type(exc).__name__}: {exc}"[:200]},
116
+ ensure_ascii=True))
117
+ return 1
118
+ print(json.dumps({"items": items}, ensure_ascii=True))
119
+ return 0
120
+
121
+
122
+ if __name__ == "__main__":
123
+ raise SystemExit(main())