argo-search 2.14.1 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/AGENTS.md +8 -6
  2. package/README.es.md +57 -813
  3. package/README.ja.md +56 -814
  4. package/README.ko.md +56 -812
  5. package/README.md +160 -754
  6. package/README.zh.md +152 -872
  7. package/SKILL.md +22 -23
  8. package/assets/readme/counts.json +1 -1
  9. package/assets/readme/hero.svg +23 -23
  10. package/backends/concept_vectors.bin +0 -0
  11. package/backends/domain_profiles.json +149 -6
  12. package/backends/engine_concept_vectors.json +1525 -1525
  13. package/backends/engine_registry.yaml +139 -30
  14. package/backends/quota_profiles.json +83 -3
  15. package/bin/argo +33 -17
  16. package/config.yaml +189 -33
  17. package/docs/ADDING_NEW_ENGINE.md +10 -0
  18. package/docs/ARGO_INTRO.md +1 -1
  19. package/docs/CHANGELOG.md +38 -0
  20. package/docs/ENGINE_CATALOG.md +102 -89
  21. package/docs/MCP_SETUP.md +10 -1
  22. package/docs/RELEASE_NOTES_v2.14.1.md +4 -4
  23. package/docs/RELEASE_NOTES_v2.15.0.md +50 -0
  24. package/docs/RELEASE_NOTES_v2.16.0.md +58 -0
  25. package/docs/RELEASING.md +1 -1
  26. package/engines/specs/ai_labs.yaml +89 -0
  27. package/engines/specs/archive_org.yaml +1 -1
  28. package/engines/specs/bilibili_hot.yaml +11 -1
  29. package/engines/specs/brave.yaml +3 -3
  30. package/engines/specs/carbon_intensity.yaml +1 -1
  31. package/engines/specs/cisa_alerts.yaml +40 -0
  32. package/engines/specs/cn_ai_news.yaml +10 -8
  33. package/engines/specs/crates.yaml +1 -1
  34. package/engines/specs/crossref.yaml +4 -2
  35. package/engines/specs/crt_sh.yaml +1 -1
  36. package/engines/specs/dblp.yaml +1 -1
  37. package/engines/specs/devto.yaml +1 -1
  38. package/engines/specs/digup.yaml +11 -6
  39. package/engines/specs/docker_hub.yaml +1 -1
  40. package/engines/specs/douyin_hot.yaml +11 -1
  41. package/engines/specs/dw_news.yaml +4 -2
  42. package/engines/specs/eng_blogs.yaml +63 -0
  43. package/engines/specs/europeana.yaml +3 -4
  44. package/engines/specs/europepmc.yaml +1 -1
  45. package/engines/specs/felo.yaml +3 -3
  46. package/engines/specs/firecrawl.yaml +3 -0
  47. package/engines/specs/fourget.yaml +5 -2
  48. package/engines/specs/france24.yaml +6 -4
  49. package/engines/specs/fxtwitter.yaml +30 -7
  50. package/engines/specs/gbfs_nyc.yaml +1 -1
  51. package/engines/specs/gleif.yaml +1 -1
  52. package/engines/specs/gov_regulations.yaml +1 -1
  53. package/engines/specs/grepapp_mcp.yaml +62 -0
  54. package/engines/specs/guardian_rss.yaml +6 -4
  55. package/engines/specs/hf_datasets.yaml +1 -1
  56. package/engines/specs/huggingface.yaml +1 -1
  57. package/engines/specs/itotii.yaml +13 -1
  58. package/engines/specs/keenable.yaml +7 -1
  59. package/engines/specs/linux_do.yaml +63 -0
  60. package/engines/specs/lobsters.yaml +41 -0
  61. package/engines/specs/local_crossref.yaml +3 -1
  62. package/engines/specs/local_github.yaml +1 -1
  63. package/engines/specs/local_npm.yaml +6 -0
  64. package/engines/specs/local_openstreetmap.yaml +1 -1
  65. package/engines/specs/local_seek.yaml +6 -0
  66. package/engines/specs/maven.yaml +1 -1
  67. package/engines/specs/mdn.yaml +1 -1
  68. package/engines/specs/musicbrainz.yaml +1 -1
  69. package/engines/specs/nasa_images.yaml +1 -1
  70. package/engines/specs/nhtsa_vpic.yaml +6 -3
  71. package/engines/specs/npm.yaml +1 -1
  72. package/engines/specs/nuget.yaml +1 -1
  73. package/engines/specs/nvd.yaml +1 -1
  74. package/engines/specs/open_meteo.yaml +1 -1
  75. package/engines/specs/openalex.yaml +4 -2
  76. package/engines/specs/openreview.yaml +1 -1
  77. package/engines/specs/polymarket.yaml +1 -1
  78. package/engines/specs/redskill.yaml +2 -0
  79. package/engines/specs/searxng.yaml +4 -2
  80. package/engines/specs/sec_edgar.yaml +9 -4
  81. package/engines/specs/steam.yaml +1 -1
  82. package/engines/specs/tinyfish.yaml +2 -0
  83. package/engines/specs/tinyfish_news.yaml +2 -0
  84. package/engines/specs/tinyfish_paper.yaml +2 -0
  85. package/engines/specs/toutiao_hot.yaml +11 -1
  86. package/engines/specs/train.yaml +3 -0
  87. package/engines/specs/twitter.yaml +4 -0
  88. package/engines/specs/unpaywall.yaml +6 -0
  89. package/engines/specs/vam.yaml +17 -3
  90. package/engines/specs/weibo_hot.yaml +11 -1
  91. package/engines/specs/wikidata.yaml +1 -1
  92. package/engines/specs/wikipedia.yaml +1 -1
  93. package/engines/specs/wolframalpha.yaml +3 -3
  94. package/engines/specs/xiaohongshu.yaml +2 -0
  95. package/engines/specs/zhihu.yaml +3 -18
  96. package/engines/specs/zhihu_hot_app.yaml +1 -1
  97. package/engines/specs/zhihu_kb.yaml +18 -0
  98. package/engines/specs/zhihu_questions.yaml +19 -0
  99. package/package.json +4 -2
  100. package/packages/dsh-plugin/README.md +9 -14
  101. package/packages/dsh-plugin/dsh/client.js +481 -1037
  102. package/packages/dsh-plugin/dsh/diagnostics.js +71 -20
  103. package/packages/dsh-plugin/dsh/index.js +6 -0
  104. package/packages/dsh-plugin/dsh/runner.js +3 -1
  105. package/packages/dsh-plugin/dsh/workbench-client.js +796 -0
  106. package/packages/dsh-plugin/dsh/workbench-md.js +386 -0
  107. package/packages/dsh-plugin/dsh/workbench-suggestions.js +148 -0
  108. package/packages/dsh-plugin/dsh/workbench.js +966 -0
  109. package/packages/dsh-plugin/icon.svg +23 -0
  110. package/packages/dsh-plugin/package.json +10 -3
  111. package/packages/dsh-plugin/scripts/sync-local.mjs +87 -0
  112. package/packages/dsh-plugin/scripts/sync-local.sh +13 -1
  113. package/packages/dsh-plugin/test/diagnostics.test.js +38 -1
  114. package/packages/dsh-plugin/test/size-gate.test.js +2 -9
  115. package/packages/dsh-plugin/test/workbench.test.js +92 -0
  116. package/scripts/adaptive.py +7 -1
  117. package/scripts/archive_run.py +112 -53
  118. package/scripts/argo_paths.py +42 -5
  119. package/scripts/badcase_ledger.py +117 -9
  120. package/scripts/build_concept_table.py +112 -55
  121. package/scripts/cache.py +6 -2
  122. package/scripts/caliber_isolation.py +60 -23
  123. package/scripts/circuit_breaker.py +72 -11
  124. package/scripts/cli_io.py +20 -2
  125. package/scripts/config_cache.py +44 -1
  126. package/scripts/daemon.py +151 -51
  127. package/scripts/dormant_ledger.py +23 -9
  128. package/scripts/engine_dispatch.py +8 -5
  129. package/scripts/engine_env.py +191 -1
  130. package/scripts/engine_families.py +50 -7
  131. package/scripts/engine_states.py +3 -50
  132. package/scripts/engine_validate.py +13 -45
  133. package/scripts/engines.py +15 -31
  134. package/scripts/engines_base.py +66 -61
  135. package/scripts/engines_builders.py +0 -15
  136. package/scripts/engines_builders_archive.py +4 -3
  137. package/scripts/engines_builders_batch10.py +346 -100
  138. package/scripts/engines_builders_batch11.py +4 -76
  139. package/scripts/engines_builders_batch13.py +4 -3
  140. package/scripts/engines_builders_batch14.py +2 -1
  141. package/scripts/engines_builders_batch15.py +2 -1
  142. package/scripts/engines_builders_batch9.py +16 -25
  143. package/scripts/engines_builders_cn.py +7 -201
  144. package/scripts/engines_builders_data.py +12 -11
  145. package/scripts/engines_builders_data_macro.py +5 -4
  146. package/scripts/engines_builders_dsh.py +2 -1
  147. package/scripts/engines_builders_feeds.py +76 -11
  148. package/scripts/engines_builders_finance.py +2 -1
  149. package/scripts/engines_builders_intl.py +18 -117
  150. package/scripts/engines_builders_media.py +59 -12
  151. package/scripts/engines_builders_pixiv.py +2 -16
  152. package/scripts/engines_builders_science.py +8 -7
  153. package/scripts/engines_builders_search.py +7 -14
  154. package/scripts/engines_builders_skill.py +2 -1
  155. package/scripts/engines_builders_tech.py +8 -17
  156. package/scripts/engines_builders_weather.py +241 -0
  157. package/scripts/engines_fields.py +91 -0
  158. package/scripts/engines_http.py +184 -0
  159. package/scripts/engines_mcp.py +405 -0
  160. package/scripts/engines_parsers.py +13 -369
  161. package/scripts/engines_schema_drift.py +260 -0
  162. package/scripts/evidence.py +13 -0
  163. package/scripts/evidence_loop.py +19 -4
  164. package/scripts/extend_route_labels.py +6 -0
  165. package/scripts/fetch_jina.py +98 -0
  166. package/scripts/fetch_jsrun.py +15 -11
  167. package/scripts/fetch_v3.py +79 -120
  168. package/scripts/fulltext_store.py +42 -1
  169. package/scripts/fxtwitter_api.py +8 -7
  170. package/scripts/gen_engine_catalog.py +2 -2
  171. package/scripts/general_pool.py +15 -4
  172. package/scripts/health_check.py +1 -1
  173. package/scripts/image_vision/vision_probe +0 -0
  174. package/scripts/install.sh +2 -0
  175. package/scripts/link_source.py +65 -24
  176. package/scripts/local_seek_adapter.py +57 -17
  177. package/scripts/matrix_search_eval.py +8 -10
  178. package/scripts/mcp_handlers.py +53 -31
  179. package/scripts/mcp_handlers_surface.py +6 -18
  180. package/scripts/mcp_transport.py +10 -5
  181. package/scripts/min_version_scan.py +7 -3
  182. package/scripts/network_aware.py +7 -13
  183. package/scripts/numeric_verify.py +3 -2
  184. package/scripts/output_transparency.py +3 -0
  185. package/scripts/pre-commit +45 -43
  186. package/scripts/query_understanding.py +30 -6
  187. package/scripts/quota.py +36 -30
  188. package/scripts/rank_signals.py +9 -0
  189. package/scripts/recompute.py +15 -5
  190. package/scripts/recovery.py +38 -29
  191. package/scripts/recovery_runner.py +29 -10
  192. package/scripts/redskill/redskill_engine.py +2 -1
  193. package/scripts/release.py +14 -26
  194. package/scripts/release_check.py +5 -25
  195. package/scripts/replay_eval.py +2 -2
  196. package/scripts/research_cli.py +40 -0
  197. package/scripts/research_notes.py +368 -0
  198. package/scripts/route.py +40 -70
  199. package/scripts/route_audit.py +259 -0
  200. package/scripts/route_combo.py +21 -6
  201. package/scripts/route_domains.py +150 -23
  202. package/scripts/route_lang.py +20 -7
  203. package/scripts/route_log.py +26 -9
  204. package/scripts/route_policy.py +85 -6
  205. package/scripts/route_telemetry_export.py +199 -0
  206. package/scripts/rrf_classic.py +5 -22
  207. package/scripts/search.py +2 -1
  208. package/scripts/search_attribution.py +53 -10
  209. package/scripts/search_entry.py +32 -1
  210. package/scripts/search_output.py +23 -11
  211. package/scripts/search_pipeline.py +15 -3
  212. package/scripts/search_rank.py +21 -11
  213. package/scripts/semantic_evidence.py +394 -178
  214. package/scripts/serp_guard.py +13 -1
  215. package/scripts/settings_page.py +4 -3
  216. package/scripts/single_flight.py +1 -1
  217. package/scripts/social_engines/hackernews_engine.py +2 -1
  218. package/scripts/social_engines/reddit_engine.py +2 -1
  219. package/scripts/social_engines/xiaohongshu_engine.py +2 -1
  220. package/scripts/social_engines/zhihu_engine.py +252 -43
  221. package/scripts/sogou_weixin_browser.py +5 -6
  222. package/scripts/source_audit.py +44 -9
  223. package/scripts/source_ledger.py +2 -15
  224. package/scripts/source_selection.py +45 -20
  225. package/scripts/straggler_policy.py +1 -2
  226. package/scripts/sync_backends.py +17 -0
  227. package/scripts/tfidf_router.py +23 -11
  228. package/scripts/time_utils.py +54 -1
  229. package/scripts/train.py +68 -2
  230. package/scripts/usage_log.py +50 -10
  231. package/scripts/watch.py +3 -3
  232. package/scripts/zhihu_quota.py +2 -1
  233. package/sub-skills/argo-wide-research/SKILL.md +70 -0
  234. package/sub-skills/ego-search/{SKILL.md → README.md} +15 -47
  235. package/sub-skills/ego-search/scripts/ego_search.py +13 -4
  236. package/sub-skills/js-run/{SKILL.md → README.md} +3 -20
  237. package/sub-skills/local-search/{SKILL.md → README.md} +3 -8
  238. package/sub-skills/local-search/engine_registry.py +32 -7
  239. package/sub-skills/local-seek/SKILL.md +20 -22
  240. package/sub-skills/local-seek/scripts/seek_fts.py +58 -3
  241. package/scripts/caliber_dedupe.py +0 -66
  242. package/scripts/engines_builders_batch16.py +0 -13
  243. package/scripts/health_probe.py +0 -253
  244. package/scripts/social_engines/twitter_engine.py +0 -514
  245. package/scripts/sync_installs.py +0 -29
@@ -0,0 +1,23 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" width="128" height="128" fill="none">
2
+ <defs>
3
+ <linearGradient id="v2-bg" x1="10" y1="8" x2="118" y2="120" gradientUnits="userSpaceOnUse">
4
+ <stop offset="0%" stop-color="#FAF6F0"/>
5
+ <stop offset="100%" stop-color="#EFE7DA"/>
6
+ </linearGradient>
7
+ <linearGradient id="v2-red" x1="34" y1="24" x2="94" y2="96" gradientUnits="userSpaceOnUse">
8
+ <stop offset="0%" stop-color="#F97316"/>
9
+ <stop offset="100%" stop-color="#DC2626"/>
10
+ </linearGradient>
11
+ </defs>
12
+
13
+ <!-- 暖砂纸底座 -->
14
+ <rect x="4" y="4" width="120" height="120" rx="28" fill="url(#v2-bg)"/>
15
+ <rect x="4.75" y="4.75" width="118.5" height="118.5" rx="27.25" stroke="#1E293B" stroke-opacity="0.10" stroke-width="1.5"/>
16
+
17
+ <!-- 平面构成:深炭黑圆环 + 赤陶红航帆 -->
18
+ <circle cx="58" cy="58" r="29" stroke="#1E293B" stroke-width="8"/>
19
+ <path d="M79 79L99 99" stroke="#1E293B" stroke-width="9" stroke-linecap="round"/>
20
+
21
+ <!-- 赤陶红立体帆面 -->
22
+ <path d="M58 34L75 73L58 66L41 73L58 34Z" fill="url(#v2-red)"/>
23
+ </svg>
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taxueseek/argo-dsh",
3
- "version": "2.14.1",
3
+ "version": "2.16.0",
4
4
  "description": "Argo 阿尔戈 — DSH plugin:argo 原生搜索/抓取工具 + web_search seam + wide_research 编排;自带设置页(接入/工具/API 密钥/研究/高级);argo MCP 19 工具全量面按需挂载。安装:dsh plugin --profile web add @taxueseek/argo-dsh(或从 GitHub main 装:dsh plugin --profile web add \"github:taxueseek/argo#main&path:packages/dsh-plugin\")",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -10,11 +10,13 @@
10
10
  "./dsh": "./dsh/index.js",
11
11
  "./specs": "./dsh/specs.js",
12
12
  "./client": "./dsh/client.js",
13
+ "./icon": "./icon.svg",
13
14
  "./cordis.patch.yml": "./cordis.patch.yml",
14
15
  "./package.json": "./package.json"
15
16
  },
16
17
  "files": [
17
18
  "dsh",
19
+ "icon.svg",
18
20
  "cordis.patch.yml",
19
21
  "README.md"
20
22
  ],
@@ -31,15 +33,20 @@
31
33
  "compatibility": {
32
34
  "dsh": "^0.2.0-rc.1 || ^0.2.1 || ^0.2.2-0",
33
35
  "dshReleases": {
34
- "0.2.2-rc.1": "compatible"
36
+ "0.2.2-rc.1": "compatible",
37
+ "0.2.2-rc.2": "compatible"
35
38
  }
36
39
  }
37
40
  },
38
41
  "engines": {
39
42
  "node": ">=18"
40
43
  },
44
+ "optionalDependencies": {
45
+ "@deepseek-ai/schemastery": "^3.19.0"
46
+ },
41
47
  "scripts": {
42
- "check": "node --check dsh/index.js && node --check dsh/specs.js && node --check dsh/runner.js && node --check dsh/wide-research.js && node --check dsh/diagnostics.js && node --check dsh/client.js",
48
+ "check": "node --check dsh/index.js && node --check dsh/specs.js && node --check dsh/runner.js && node --check dsh/wide-research.js && node --check dsh/diagnostics.js && node --check dsh/client.js && node --check scripts/sync-local.mjs",
49
+ "sync-local": "node scripts/sync-local.mjs",
43
50
  "typecheck": "npm run check",
44
51
  "test": "node --test test/*.test.js"
45
52
  }
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * sync-local.mjs — 跨平台(Windows/macOS/Linux)将本仓 packages/dsh-plugin 同步到本机 DSH profile。
4
+ * 用法:
5
+ * node scripts/sync-local.mjs # 同步 web,desktop(或 DSH_PROFILES)
6
+ * node scripts/sync-local.mjs web # 只同步指定 profile
7
+ * node scripts/sync-local.mjs --check # 只比对不写,有漂移退出 1
8
+ */
9
+ import fs from 'node:fs';
10
+ import os from 'node:os';
11
+ import path from 'node:path';
12
+ import { fileURLToPath } from 'node:url';
13
+
14
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
15
+ const SRC = path.resolve(__dirname, '..');
16
+ const DSH_HOME = process.env.DSH_HOME || path.join(os.homedir(), '.dsh');
17
+
18
+ let mode = 'sync';
19
+ const profiles = [];
20
+ for (const arg of process.argv.slice(2)) {
21
+ if (arg === '--check') mode = 'check';
22
+ else if (arg === '--restart') {
23
+ console.error('[removed] --restart 已移除:同步产物不等于激活 Host');
24
+ process.exit(2);
25
+ } else if (arg === '-h' || arg === '--help') {
26
+ console.log('Usage: node scripts/sync-local.mjs [--check] [profile...]');
27
+ process.exit(0);
28
+ } else profiles.push(arg);
29
+ }
30
+
31
+ if (profiles.length === 0) {
32
+ const raw = process.env.DSH_PROFILES || 'web,desktop';
33
+ profiles.push(...raw.split(',').map((s) => s.trim()).filter(Boolean));
34
+ }
35
+
36
+ function filesEqual(a, b) {
37
+ if (!fs.existsSync(a) || !fs.existsSync(b)) return false;
38
+ const sa = fs.statSync(a), sb = fs.statSync(b);
39
+ if (sa.isDirectory() && sb.isDirectory()) {
40
+ const ea = fs.readdirSync(a).sort(), eb = fs.readdirSync(b).sort();
41
+ if (ea.length !== eb.length || ea.some((x, i) => x !== eb[i])) return false;
42
+ return ea.every((name) => filesEqual(path.join(a, name), path.join(b, name)));
43
+ }
44
+ if (sa.isFile() && sb.isFile()) {
45
+ if (sa.size !== sb.size) return false;
46
+ return Buffer.compare(fs.readFileSync(a), fs.readFileSync(b)) === 0;
47
+ }
48
+ return false;
49
+ }
50
+
51
+ const ts = new Date().toISOString().replace(/[-:]/g, '').replace('T', '-').slice(0, 15);
52
+ let drift = 0;
53
+
54
+ for (const p of profiles) {
55
+ const dest = path.join(DSH_HOME, 'profiles', p, 'node_modules', '@taxueseek', 'argo-dsh');
56
+ let lst;
57
+ try { lst = fs.lstatSync(dest); } catch {
58
+ console.log(`[skip] ${p}: 未安装 ${dest}`);
59
+ continue;
60
+ }
61
+ if (lst.isSymbolicLink() && fs.realpathSync(dest) === fs.realpathSync(SRC)) {
62
+ console.log(mode === 'check' ? `[ok] ${p} (symlink)` : `[skip] ${p}: 已是直连 symlink`);
63
+ continue;
64
+ }
65
+ if (mode === 'check') {
66
+ const same = filesEqual(path.join(SRC, 'dsh'), path.join(dest, 'dsh'))
67
+ && filesEqual(path.join(SRC, 'package.json'), path.join(dest, 'package.json'));
68
+ if (same) console.log(`[ok] ${p}`);
69
+ else {
70
+ console.log(`[drift] ${p}: 源码与已安装 bundle 不一致,请运行 npm run sync-local`);
71
+ drift = 1;
72
+ }
73
+ continue;
74
+ }
75
+ const bakDir = path.join(DSH_HOME, 'backups', `argo-dsh-sync-${ts}-${p}`);
76
+ fs.mkdirSync(path.dirname(bakDir), { recursive: true });
77
+ fs.cpSync(dest, bakDir, { recursive: true, force: true });
78
+ fs.rmSync(path.join(dest, 'dsh'), { recursive: true, force: true });
79
+ fs.cpSync(path.join(SRC, 'dsh'), path.join(dest, 'dsh'), { recursive: true, force: true });
80
+ for (const f of ['package.json', 'cordis.patch.yml', 'README.md']) {
81
+ fs.copyFileSync(path.join(SRC, f), path.join(dest, f));
82
+ }
83
+ console.log(`[synced] ${p}`);
84
+ }
85
+
86
+ if (mode === 'check') process.exit(drift);
87
+ console.log('[artifact-synced] 产物已同步;请核对 Host 运行态');
@@ -45,10 +45,22 @@ drift=0
45
45
 
46
46
  for p in "${PROFILES[@]}"; do
47
47
  DEST="$DSH_HOME/profiles/$p/node_modules/@taxueseek/argo-dsh"
48
- if [ ! -d "$DEST" ]; then
48
+ if [ ! -e "$DEST" ] && [ ! -L "$DEST" ]; then
49
49
  echo "[skip] $p: 未安装 $DEST"
50
50
  continue
51
51
  fi
52
+ if [ -L "$DEST" ]; then
53
+ REAL_DEST="$(cd "$DEST" 2>/dev/null && pwd -P || true)"
54
+ REAL_SRC="$(cd "$SRC" && pwd -P)"
55
+ if [ "$REAL_DEST" = "$REAL_SRC" ]; then
56
+ if [ "$MODE" = check ]; then
57
+ echo "[ok] $p (symlink)"
58
+ else
59
+ echo "[skip] $p: 已是直连 symlink,无需拷贝同步"
60
+ fi
61
+ continue
62
+ fi
63
+ fi
52
64
  if [ "$MODE" = check ]; then
53
65
  if diff -rq "$SRC/dsh" "$DEST/dsh" >/dev/null 2>&1 \
54
66
  && cmp -s "$SRC/package.json" "$DEST/package.json"; then
@@ -1,6 +1,9 @@
1
1
  import { test } from 'node:test'
2
2
  import assert from 'node:assert/strict'
3
- import { getMcpPoolStats, resetMcpPool } from '../dsh/diagnostics.js'
3
+ import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs'
4
+ import { join } from 'node:path'
5
+ import { tmpdir } from 'node:os'
6
+ import { getMcpPoolStats, getRouteHealth, resetMcpPool, resolveStateDir } from '../dsh/diagnostics.js'
4
7
 
5
8
  test('diagnostics: getMcpPoolStats returns pool status and active loads', () => {
6
9
  const dummyPool = [
@@ -26,3 +29,37 @@ test('diagnostics: resetMcpPool evicts connections safely', () => {
26
29
  assert.equal(result.poolSizeNow, 0)
27
30
  assert.equal(closed, 2)
28
31
  })
32
+
33
+ test('diagnostics: getRouteHealth reads real route.jsonl fields and summary without query', async () => {
34
+ const dir = mkdtempSync(join(tmpdir(), 'argo-diag-'))
35
+ try {
36
+ mkdirSync(join(dir, 'usage_log'), { recursive: true })
37
+ const rows = [
38
+ JSON.stringify({ domain: 'code_search', engine: 'github', engines: ['github', 'anysearch'], primary_lang: 'en', effective_lang: 'en', confidence: 0.92, mode: 'auto', intents: ['fact'], ts: '2026-11-15T10:00:00Z' }),
39
+ JSON.stringify({ domain: null, engine: 'anysearch', engines: ['anysearch', 'local_bing'], primary_lang: 'en', effective_lang: 'es', confidence: 0.65, mode: 'fast', intents: ['news'], ts: '2026-11-15T10:01:00Z' }),
40
+ ]
41
+ writeFileSync(join(dir, 'usage_log', 'route.jsonl'), rows.join('\n') + '\n', 'utf8')
42
+ const health = await getRouteHealth(dir, 5)
43
+ assert.equal(health.samples.length, 2)
44
+ assert.equal(health.samples[0].domain, 'code_search')
45
+ assert.equal(health.samples[1].effective_lang, 'es')
46
+ assert.equal('query' in health.samples[0], false)
47
+ assert.equal(health.summary.total, 2)
48
+ assert.equal(health.summary.fallbackCount, 1)
49
+ assert.equal(health.summary.fallbackRate, 0.5)
50
+ assert.equal(health.summary.langCounts.es, 1)
51
+ } finally {
52
+ rmSync(dir, { recursive: true, force: true })
53
+ }
54
+ })
55
+
56
+ test('diagnostics: resolveStateDir honors ARGO_STATE_DIR env override', () => {
57
+ const prev = process.env.ARGO_STATE_DIR
58
+ process.env.ARGO_STATE_DIR = '/tmp/argo-custom-state-test'
59
+ try {
60
+ assert.equal(resolveStateDir(), '/tmp/argo-custom-state-test')
61
+ } finally {
62
+ if (prev === undefined) delete process.env.ARGO_STATE_DIR
63
+ else process.env.ARGO_STATE_DIR = prev
64
+ }
65
+ })
@@ -31,15 +31,8 @@ const DSH_DIR = join(PKG_ROOT, 'dsh')
31
31
 
32
32
  const HARD_LIMIT = 1000
33
33
 
34
- // 路径 → [上限行数, 为什么不拆/拆到哪一步]
35
- const GRANDFATHERED = new Map([
36
- ['dsh/client.js', [
37
- 1548,
38
- 'web 设置面板单页(接入/工具/密钥/研究/高级五段 UI + 状态机);' +
39
- '2026-11-09 同步新增独立引擎(mojeek、repology 等)声明密钥至 1,548;' +
40
- '拆分候选:把各段表单渲染抽成 render-* 模块,状态机留在本文件',
41
- ]],
42
- ])
34
+ // 路径 → [上限行数, 为什么不拆/拆到哪一步](client.js 经 schema 驱动重构已降至千行以内,清单清零)
35
+ const GRANDFATHERED = new Map()
43
36
 
44
37
  function lineCount(file) {
45
38
  const text = readFileSync(file, 'utf8')
@@ -0,0 +1,92 @@
1
+ import test from 'node:test'
2
+ import assert from 'node:assert/strict'
3
+ import { EventEmitter } from 'node:events'
4
+ import { createWorkbenchHandler } from '../dsh/workbench.js'
5
+
6
+ function mockReq(method, url, bodyObj = null) {
7
+ const req = new EventEmitter()
8
+ req.method = method
9
+ req.url = url
10
+ req.headers = { host: '127.0.0.1:8080' }
11
+ queueMicrotask(() => {
12
+ if (bodyObj !== null) req.emit('data', Buffer.from(JSON.stringify(bodyObj)))
13
+ req.emit('end')
14
+ })
15
+ return req
16
+ }
17
+
18
+ function mockRes() {
19
+ const headers = {}
20
+ let chunks = ''
21
+ return {
22
+ statusCode: 200,
23
+ writableEnded: false,
24
+ destroyed: false,
25
+ setHeader(k, v) { headers[k.toLowerCase()] = v },
26
+ end(data = '') {
27
+ chunks += String(data)
28
+ this.writableEnded = true
29
+ },
30
+ json() { return JSON.parse(chunks || '{}') },
31
+ text() { return chunks },
32
+ headers,
33
+ }
34
+ }
35
+
36
+ test('workbench /argo/api/health exposes local mode, egoSearch and breaker summary', async () => {
37
+ const handler = createWorkbenchHandler({}, {}, () => ({}))
38
+ try {
39
+ const res = mockRes()
40
+ await handler(mockReq('GET', '/argo/api/health'), res)
41
+ assert.equal(res.statusCode, 200)
42
+ const data = res.json()
43
+ assert.equal(data.ok, true)
44
+ assert.ok(Array.isArray(data.modes))
45
+ assert.ok(data.modes.some(m => m.id === 'local'))
46
+ assert.ok(data.modes.some(m => m.id === 'plugin'))
47
+ assert.equal(typeof data.egoSearch?.enabled, 'boolean')
48
+ assert.equal(typeof data.breaker?.total, 'number')
49
+ } finally {
50
+ handler.dispose()
51
+ }
52
+ })
53
+
54
+ test('workbench serves workbench-client.js and rejects missing query on /argo/api/stream', async () => {
55
+ const handler = createWorkbenchHandler({}, {}, () => ({}))
56
+ try {
57
+ const resJs = mockRes()
58
+ await handler(mockReq('GET', '/argo/workbench-client.js'), resJs)
59
+ assert.equal(resJs.statusCode, 200)
60
+ assert.ok(resJs.text().includes('mountArgoWorkbench'))
61
+
62
+ const resErr = mockRes()
63
+ await handler(mockReq('GET', '/argo/api/stream?mode=plugin'), resErr)
64
+ assert.equal(resErr.statusCode, 400)
65
+ assert.equal(resErr.json().error, 'missing_query')
66
+ } finally {
67
+ handler.dispose()
68
+ }
69
+ })
70
+
71
+ test('workbench /argo/api/suggestions adapts to mode and DSH locale', async () => {
72
+ const handler = createWorkbenchHandler({}, {}, () => ({}))
73
+ try {
74
+ const resZh = mockRes()
75
+ await handler(mockReq('GET', '/argo/api/suggestions?mode=hotspot&lang=zh'), resZh)
76
+ assert.equal(resZh.statusCode, 200)
77
+ const zh = resZh.json()
78
+ assert.equal(zh.ok, true)
79
+ assert.equal(zh.lang, 'zh')
80
+ assert.ok(zh.items.length > 0)
81
+
82
+ const resEn = mockRes()
83
+ await handler(mockReq('GET', '/argo/api/suggestions?mode=plugin&lang=en'), resEn)
84
+ assert.equal(resEn.statusCode, 200)
85
+ const en = resEn.json()
86
+ assert.equal(en.ok, true)
87
+ assert.equal(en.lang, 'en')
88
+ assert.ok(en.items.some(it => it.tag === 'Mode'))
89
+ } finally {
90
+ handler.dispose()
91
+ }
92
+ })
@@ -128,9 +128,15 @@ def scenario_of(decision: dict | None) -> dict[str, str]:
128
128
  """
129
129
  d = decision or {}
130
130
  feats = d.get("features") or {}
131
+ lang = str(
132
+ feats.get("lang_override")
133
+ or feats.get("effective_lang")
134
+ or feats.get("primary_lang")
135
+ or ""
136
+ )
131
137
  return {
132
138
  "domain": str(d.get("domain") or ""),
133
- "lang": str(feats.get("primary_lang") or ""),
139
+ "lang": lang,
134
140
  }
135
141
 
136
142
 
@@ -26,9 +26,8 @@ archive_run.py — 搜索/研究 run 工作区归档
26
26
 
27
27
  默认根目录解析顺序:
28
28
  1. ARGO_ARCHIVE_ROOT
29
- 2. 工作区存在 AGENTS.md 时 → <workspace>/数据/argo-search-archive
30
- 3. ./数据/argo-search-archive(若父级 数据/ 可建)
31
- 4. ./argo-search-archive
29
+ 2. 兼容既有工作区目录:<workspace>/数据/argo-search-archive(若存在)
30
+ 3. 规范化项目标准级惯例:<workspace>/docs/research/archive 或 <workspace>/research/archive
32
31
  """
33
32
 
34
33
  from __future__ import annotations
@@ -138,17 +137,35 @@ def resolve_archive_root(explicit: str | Path | None = None) -> Path:
138
137
  if env:
139
138
  return Path(env).expanduser().resolve()
140
139
 
141
- # 向上找带 AGENTS.md 的工作区
142
- cwd = Path.cwd().resolve()
143
- for p in [cwd, *cwd.parents]:
144
- if (p / "AGENTS.md").is_file():
145
- root = p / "数据" / "argo-search-archive"
146
- return root
147
- if p == p.parent:
148
- break
140
+ # 与 research_notes 共用同一个基目录,避免「笔记在 research/、归档在
141
+ # docs/research/archive/」的首次使用分叉。
142
+ from research_notes import find_workspace_root, resolve_research_base
143
+ ws = find_workspace_root()
149
144
 
150
- data_local = cwd / "数据" / "argo-search-archive"
151
- return data_local
145
+ # 1. 兼容既有特定工作区归档目录(如母仓历史沿用的 数据/argo-search-archive)
146
+ legacy_root = ws / "数据" / "argo-search-archive"
147
+ if legacy_root.is_dir():
148
+ return legacy_root
149
+
150
+ # 2. 笔记基目录下的 archive/(docs/research/archive 或 research/archive)
151
+ base = resolve_research_base(ws)
152
+ try:
153
+ from research_notes import should_anchor_workspace
154
+ anchor = should_anchor_workspace(ws)
155
+ except Exception:
156
+ # 探测不可用不赌工作区:结论进用户级持久区。与 research_notes 的
157
+ # 兜底同一口径(宁落持久区,不落易失区),见 workspace_anchorable。
158
+ anchor = False
159
+ if anchor:
160
+ return base / "archive"
161
+
162
+ # 3. 工作区不可锚定(容器、无持久盘):退回用户级文档目录,随环境销毁
163
+ # 会丢掉全部归档证据。与缓存分开(缓存可清,归档不可丢)。
164
+ try:
165
+ from argo_paths import research_root
166
+ return research_root().expanduser().resolve() / "archive"
167
+ except Exception:
168
+ return base / "archive"
152
169
 
153
170
 
154
171
  def make_run_id(query: str, when: datetime | None = None) -> str:
@@ -160,57 +177,99 @@ def make_run_id(query: str, when: datetime | None = None) -> str:
160
177
 
161
178
  def search_archive(query: str, root: Path | None = None,
162
179
  since: str | None = None, until: str | None = None,
163
- limit: int = 10) -> list[dict[str, Any]]:
180
+ limit: int = 10,
181
+ include_notes: bool = False) -> list[dict[str, Any]]:
164
182
  """检索归档索引(成果复用):主题词命中的历史研究/搜索 run。
165
183
 
166
184
  - 数据源:{root}/index.jsonl(无索引时返回空)
167
185
  - 过滤:query/tag/note 子串命中(query 必需);packed_at 日期窗可选
186
+ - include_notes=True 时并入 research_notes 的 research-index.jsonl,
187
+ 让「上次得到的结论」也能被搜到——只搜证据不搜结论,等于每次从零开始
168
188
  - 返回:run_id / packed_at / query / tag / source / counts / run_dir
169
189
  """
170
190
  archive_root = (root or resolve_archive_root()).expanduser().resolve()
171
191
  index_path = archive_root / "index.jsonl"
172
- if not index_path.exists():
173
- return []
174
192
  kw = (query or "").strip().lower()
175
193
  out: list[dict[str, Any]] = []
176
- try:
177
- with index_path.open(encoding="utf-8") as f:
178
- for line in f:
179
- line = line.strip()
180
- if not line:
181
- continue
182
- try:
183
- row = json.loads(line)
184
- except ValueError:
185
- continue
186
- hay = " ".join([
187
- str(row.get("query") or ""),
188
- str(row.get("tag") or ""),
189
- str(row.get("note") or ""),
190
- ]).lower()
191
- if kw and kw not in hay:
192
- continue
193
- packed = str(row.get("packed_at") or "")
194
- day = packed[:10]
195
- if since and day and day < since:
196
- continue
197
- if until and day and day > until:
194
+ if index_path.exists():
195
+ try:
196
+ with index_path.open(encoding="utf-8") as f:
197
+ for line in f:
198
+ line = line.strip()
199
+ if not line:
200
+ continue
201
+ try:
202
+ row = json.loads(line)
203
+ except ValueError:
204
+ continue
205
+ hay = " ".join([
206
+ str(row.get("query") or ""),
207
+ str(row.get("tag") or ""),
208
+ str(row.get("note") or ""),
209
+ ]).lower()
210
+ if kw and kw not in hay:
211
+ continue
212
+ packed = str(row.get("packed_at") or "")
213
+ day = packed[:10]
214
+ if since and day and day < since:
215
+ continue
216
+ if until and day and day > until:
217
+ continue
218
+ out.append({
219
+ "run_id": row.get("run_id"),
220
+ "packed_at": packed,
221
+ "query": row.get("query"),
222
+ "tag": row.get("tag"),
223
+ "source": row.get("source"),
224
+ "status": row.get("status"),
225
+ "counts": row.get("counts") or {},
226
+ "run_dir": row.get("run_dir"),
227
+ })
228
+ if len(out) >= limit:
229
+ break
230
+ except OSError:
231
+ return out
232
+
233
+ if include_notes and kw:
234
+ try:
235
+ from research_notes import search_index as _search_notes, resolve_root as _resolve_note_root
236
+ # 笔记索引根与归档根**不是同一个目录**:8ec0501 起归档在
237
+ # `<base>/archive/`,笔记在 `<base>/`,索引是 `<base>/research-index.jsonl`。
238
+ # 只传 archive_root 时 `_search_notes` 读不到索引,`--include-notes`
239
+ # 永远空结果(实测:传 archive_root 得 [],传 note root 得命中)。
240
+ # 候选根取「笔记根 + 归档根 + 归档根的父目录」:
241
+ # - 笔记根:ARGO_RESEARCH_ROOT 与 ARGO_ARCHIVE_ROOT 分设时仍然命中
242
+ # - 归档根 / 其父:共用基目录布局(archive 与笔记同基)
243
+ # 三者去重后合并,任一根有索引都能搜到。
244
+ candidates: list[Path] = []
245
+ for cand in (_resolve_note_root(), archive_root, archive_root.parent):
246
+ rc = cand.expanduser().resolve()
247
+ if rc not in candidates:
248
+ candidates.append(rc)
249
+ seen: set[str] = set()
250
+ for cand in candidates:
251
+ if not (cand / "research-index.jsonl").is_file():
198
252
  continue
199
- out.append({
200
- "run_id": row.get("run_id"),
201
- "packed_at": packed,
202
- "query": row.get("query"),
203
- "tag": row.get("tag"),
204
- "source": row.get("source"),
205
- "status": row.get("status"),
206
- "counts": row.get("counts") or {},
207
- "run_dir": row.get("run_dir"),
208
- })
209
- if len(out) >= limit:
210
- break
211
- except OSError:
212
- return []
213
- return out
253
+ for row in _search_notes(kw, root=cand, limit=limit):
254
+ key = f"{row.get('kind')}:{row.get('slug')}"
255
+ if key in seen:
256
+ continue
257
+ seen.add(key)
258
+ out.append({
259
+ "run_id": f"note:{row.get('kind')}:{row.get('slug')}",
260
+ "packed_at": row.get("created_at"),
261
+ "query": row.get("title"),
262
+ "tag": row.get("kind"),
263
+ "source": "research_note",
264
+ "status": "completed",
265
+ "counts": {},
266
+ "run_dir": str(row.get("note_file")),
267
+ "note_slug": row.get("slug"),
268
+ "note_kind": row.get("kind"),
269
+ })
270
+ except Exception:
271
+ pass
272
+ return out[:limit]
214
273
 
215
274
 
216
275
  def write_search_archive(
@@ -14,8 +14,8 @@ health.db 等文件,测试也难以整体隔离。
14
14
  - 各模块只声明「文件名」,不再各自拼目录
15
15
  - `python3 scripts/argo_paths.py [--json]` 可打印关键路径的实际来源
16
16
 
17
- 注意:User-Agent 里的 unified-search@local 是邮箱标识,与状态目录无关,
18
- 不在此处管理。
17
+ 注意:历史 User-Agent 里的邮箱标识与状态目录命名无关,不在此处管理;
18
+ UA 已收敛到 engines_http.UA 单源(2026-11-18)。
19
19
  """
20
20
 
21
21
  from __future__ import annotations
@@ -34,6 +34,8 @@ ENV_STATE_DIR = "ARGO_STATE_DIR"
34
34
  # 平台惯例变量(只读,不新增 argo 私有名字)
35
35
  ENV_XDG_CACHE = "XDG_CACHE_HOME"
36
36
  ENV_LOCALAPPDATA = "LOCALAPPDATA"
37
+ # 研究结论归档的独立覆盖名(与缓存分离:缓存可清,结论不可丢)
38
+ ENV_RESEARCH_DIR = "ARGO_RESEARCH_ROOT"
37
39
 
38
40
  # 历史默认目录(也是 config.yaml 中 db_path 的默认前缀)
39
41
  _LEGACY_ROOT = "~/.cache/unified-search"
@@ -112,6 +114,41 @@ def state_root() -> Path:
112
114
  return platform_cache_default()
113
115
 
114
116
 
117
+ def research_root() -> Path:
118
+ """研究结论归档的**独立**根目录,与缓存分开(缓存可清,结论不可丢)。
119
+
120
+ 为什么不复用 state_root:state_root 的语义是「可重建的派生状态」——
121
+ 缓存、配额计数、健康度都能删,删了最多重跑。研究笔记是**用户产出**,
122
+ 删掉不可恢复。两者放进同一个可清理区,用户清缓存时会连带丢掉全部
123
+ 研究结论(第一性原理:保留策略不同的数据不该共享生命周期)。
124
+
125
+ 优先级:
126
+ 1. ARGO_RESEARCH_ROOT(显式覆盖,容器/多机指向挂载卷时用它)
127
+ 2. 平台惯例的**文档**目录(不是缓存目录):
128
+ macOS → ~/Documents/argo-research
129
+ Windows → %USERPROFILE%\\Documents\\argo-research
130
+ POSIX → $XDG_DOCUMENTS_DIR(未设则 ~/Documents/argo-research)
131
+
132
+ 注意:工作区内的 docs/research 或 research/ 由 research_notes.resolve_root
133
+ 负责,那是**项目级**归档(跟着仓库走、可提交、可共享给协作者);本函数
134
+ 是**用户级**兜底,只在没有工作区可锚定时使用,不参与项目内归档。
135
+ """
136
+ override = os.environ.get(ENV_RESEARCH_DIR, "").strip()
137
+ if override:
138
+ return Path(os.path.expanduser(override))
139
+
140
+ env = os.environ
141
+ platform = sys.platform
142
+ if platform == "darwin":
143
+ base = Path.home() / "Documents"
144
+ elif platform.startswith("win"):
145
+ base = Path(os.path.expanduser(str(env.get("USERPROFILE") or "~"))) / "Documents"
146
+ else:
147
+ xdg_docs = str(env.get("XDG_DOCUMENTS_DIR") or "").strip()
148
+ base = Path(os.path.expanduser(xdg_docs)) if xdg_docs else Path.home() / "Documents"
149
+ return base / "argo-research"
150
+
151
+
115
152
  def resolved_paths() -> dict[str, str]:
116
153
  """诊断用:把关键路径的**实际来源**摊开(`python3 scripts/argo_paths.py`)。
117
154
 
@@ -130,6 +167,7 @@ def resolved_paths() -> dict[str, str]:
130
167
  else:
131
168
  out["state_source"] = "平台惯例默认"
132
169
  out["state_root"] = str(state_root())
170
+ out["research_root"] = str(research_root())
133
171
  out["platform_cache_default"] = str(platform_cache_default())
134
172
  out["legacy_root"] = str(Path(os.path.expanduser(_LEGACY_ROOT)))
135
173
  try:
@@ -325,8 +363,8 @@ def run_checks(lock_hold_s: float = 0.15) -> list[dict[str, Any]]:
325
363
 
326
364
  `lock_hold_s` 是子进程持锁时长,判据是「第二个持有者等待 ≥100 ms」(见
327
365
  `_check_lock_roundtrip`),0.15 s 留足一倍余量即可。历史上这里写 0.6 s,
328
- 让每次自检固定空等 600 ms;同仓 `packages/argo-zcode/server/py_bridge.py`
329
- 与 `tests/test_platform_paths_conventions.py` 早已分别用 0.15 / 0.2,
366
+ 让每次自检固定空等 600 ms;`tests/test_platform_paths_conventions.py` 早已
367
+ 用 0.2(原插件桥测试用 0.15,随 2026-11-13 ZCode 插件剥离退出),
330
368
  此处对齐同一口径,自检结论不变。
331
369
  """
332
370
  checks: list[dict[str, Any]] = []
@@ -477,7 +515,6 @@ def _config_db_path() -> str | None:
477
515
  def state_path(*parts: str) -> Path:
478
516
  """返回状态根目录下的路径(不自动创建目录)。
479
517
 
480
- state_path("health.db") → <root>/health.db
481
518
  state_path("admission", "x.json") → <root>/admission/x.json
482
519
  """
483
520
  return state_root().joinpath(*parts)