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
@@ -0,0 +1,57 @@
1
+ # 秘塔 AI 搜索 · 学术档(官方 API,scope: scholar)
2
+ #
3
+ # 上游:POST https://metaso.cn/api/v1/search,scope=scholar。返回 scholars[]:
4
+ # title/link/snippet/score/position/date(ISO YYYY-MM-DD)/authors(部分条目)。
5
+ #
6
+ # 这是什么通道:题录聚合,不是库内检索。中文条目落在
7
+ # s.wanfangdata.com.cn(link 是万方检索页 URL,snippet 常为空,无 authors)
8
+ # www.cqvip.com(有 authors + date + snippet)
9
+ # 英文条目落在 doi.org / semanticscholar.org。知网题录 2024-08 起已从秘塔
10
+ # 下线(知网侵权告知函后官方公告「不再收录知网文献的题录及摘要数据」),
11
+ # 因此本档覆盖万方 + 维普,不含 CNKI。链接为二次检索入口,核对原文需再
12
+ # 一步跳转——要直接可读的原文直链用 metaso_doc。
13
+ #
14
+ # 网页端学术模式的「中文库/英文库 + 北大核心/中科院分区/JCR/SCIE/EI」筛选
15
+ # 在开放 API 侧没有对应参数(scope 之外的筛选参数上游未公开),本档拿不到
16
+ # 分区/核心级别。
17
+ #
18
+ # 计费与显式调用纪律同 metaso.yaml(按次 0.03 元;固定 size: 20 同价取满;
19
+ # explicit_only 不进自动路由)。
20
+ #
21
+ # 验证:
22
+ # python3 scripts/engine_validate.py --engine metaso_scholar --stage all --admit --write-doc
23
+
24
+ engine_id: metaso_scholar
25
+ type: http
26
+ enabled: true
27
+ explicit_only: true
28
+ cost_tier: low
29
+ method: POST
30
+ url: https://metaso.cn/api/v1/search
31
+ timeout: 15
32
+ canary_query: "唯物史观"
33
+ label: 秘塔学术(题录)
34
+ family: academic
35
+ priority: 58
36
+ cost_per_call: 0.03
37
+ cost_unit: cny
38
+ required_env:
39
+ - ARGO_METASO_API_KEY
40
+
41
+ headers:
42
+ Authorization: Bearer {ARGO_METASO_API_KEY}
43
+ Content-Type: application/json
44
+
45
+ body:
46
+ q: "{query}"
47
+ scope: scholar
48
+ size: 20
49
+
50
+ output_map:
51
+ items: scholars
52
+ item_title: title
53
+ item_url: link
54
+ item_summary: snippet
55
+ item_published_at: date
56
+
57
+ coverage: [academic, paper, chinese]
@@ -0,0 +1,62 @@
1
+ # 秘塔 AI 搜索 · 视频档(官方 API)
2
+ #
3
+ # 上游与鉴权同 metaso.yaml:POST https://metaso.cn/api/v1/search,鉴权头
4
+ # Authorization: Bearer {ARGO_METASO_API_KEY}。计价按次扣积分,与返回条数无关
5
+ # (实测 size=3 与 size=20 同价),故 size 固定取满,条数裁剪交给调用方 n。
6
+ #
7
+ # 结果形态:videos[] —— title/link/score/snippet/position/authors/date/duration/
8
+ # coverImage。四处用前须知:
9
+ # - date 是 ISO(YYYY-MM-DD),但 metaso 家族未列入 scripts/time_utils.py 的
10
+ # TIME_CAPABLE_ENGINES,published_at 只作展示透传,--since/--until 不生效。
11
+ # - duration 是秒数字符串,output_map 无对应槽位,不透传。
12
+ # - coverImage 是图床直链(实测为 http 而非 https),映射到 item_image 供结果
13
+ # 卡展示;上游不给授权信息,与 metaso_image 同为「许可未判定」。
14
+ # - authors 是数组,output_map 无数组槽位,不透传。
15
+ # score 是 low/medium/high 这类字符串(非数值),透传到 upstream_score。
16
+ #
17
+ # 路由形态:explicit_only —— 只经 `argo search --engine metaso_video` 显式调用,
18
+ # 不参与任何域的自动选择。
19
+ #
20
+ # 验证:
21
+ # python3 scripts/engine_validate.py --engine metaso_video --stage all --admit --write-doc
22
+
23
+ engine_id: metaso_video
24
+ type: http
25
+ enabled: true
26
+ explicit_only: true
27
+ cost_tier: low
28
+ method: POST
29
+ url: https://metaso.cn/api/v1/search
30
+ timeout: 15
31
+ canary_query: "人工智能"
32
+ label: 秘塔搜索(视频)
33
+ family: misc_vertical
34
+ priority: 33
35
+ cost_per_call: 0.03
36
+ cost_unit: cny
37
+ required_env:
38
+ - ARGO_METASO_API_KEY
39
+
40
+ headers:
41
+ Authorization: Bearer {ARGO_METASO_API_KEY}
42
+ Content-Type: application/json
43
+
44
+ body:
45
+ q: "{query}"
46
+ scope: video
47
+ size: 20
48
+
49
+ output_map:
50
+ items: videos
51
+ item_title: title
52
+ item_url: link
53
+ item_summary: snippet
54
+ item_published_at: date
55
+ item_image: coverImage
56
+ item_upstream_score: score
57
+
58
+ coverage: [tv, media, entertainment]
59
+
60
+ quality_queries:
61
+ - query: "人工智能"
62
+ - query: "纪录片"
@@ -0,0 +1,44 @@
1
+ # NCPSSD(国家哲学社会科学文献中心)—— 中文社科期刊文献检索。
2
+ #
3
+ # 是什么:国社科文献中心检索页背后的表单接口(上游自述 2000+ 期刊、930 万+ 篇),
4
+ # 能拿到题录 + 作者/刊名/年卷期页 + 摘要,多数条目另带一份 PDF 直链。
5
+ # 覆盖边界:**只有中文社科文献**(期刊论文为主);题录与摘要取自上游检索响应,
6
+ # PDF 是上游返回的直链、可下载性随上游策略变化;不含外文文献与古籍。
7
+ # 接口形态:上游只吃表单 POST(GET 返回 HTML、空体 POST 被 WAF 拒),argo 的
8
+ # 声明式 http 引擎不发这种请求,故走 CLI 桥 scripts/ncpssd_bridge.py 代发并转成 items。
9
+ # 计费:免费(无 key)。
10
+ # 稳定面:端点与参数由检索页逆向所得,无公开 API 文档、站点也无 robots 声明,
11
+ # 上游改版即可能失效;因此 explicit_only: true —— 不参与自动路由,只在显式点名时调用。
12
+ # 验证:python3 scripts/engine_validate.py --engine ncpssd --stage all --admit
13
+ # python3 scripts/search.py "唯物史观" --engine ncpssd --json
14
+ engine_id: ncpssd
15
+ type: cli
16
+ enabled: true
17
+ explicit_only: true
18
+ cost_tier: free
19
+ canary_query: "唯物史观"
20
+ relevance_check: true
21
+ label: 国家哲学社会科学文献中心(中文期刊题录+全文PDF)
22
+ desc: NCPSSD(国家哲学社会科学文献中心)——中文期刊/集刊题录与摘要,命中常带全文 PDF 直链(表单 POST 经 CLI 桥)
23
+ family: academic
24
+ coverage: [chinese, academic, paper]
25
+ # 质量门禁自述查询集:默认质量集是英文通用探针,打在纯中文源上会与结果零词面交集,
26
+ # 被相关性判据封顶 0.3 判 fail(实测);按「引擎声明自己的适用集」的既有做法给中文社科查询。
27
+ quality_queries:
28
+ - query: "唯物史观"
29
+ - query: "中国式现代化"
30
+ - query: "乡村振兴"
31
+ - query: "数字经济"
32
+ - query: "社会保障"
33
+ cmd:
34
+ - python3
35
+ - scripts/ncpssd_bridge.py
36
+ search_args:
37
+ - "{query}"
38
+ - "-n"
39
+ - "{n}"
40
+ output_format: yaml
41
+ timeout: 25
42
+ # 无 PDF 直链的条目只有题录(标题/作者/刊名/年卷期页),按 issue #29 口径 B 声明
43
+ # 本档条目不以 url 为身份:缺 url 不再被 SERP 闸当壳页整批吞(见 serp_guard.is_unusable_row)。
44
+ url_kind: none
@@ -0,0 +1,73 @@
1
+ # Sciverse · 学术题录检索(官方 HTTP API,POST /meta-search,需 token)
2
+ #
3
+ # 上游:OpenDataLab / MinerU(上海人工智能实验室)的科研数据基座,
4
+ # base https://api.sciverse.space,鉴权头 Authorization: Bearer <token>。
5
+ # 契约取自官方 Python SDK sciverse 0.14.3 源码(client.py:155-182 的
6
+ # search_papers 与 client.py:34-101 的 _to_backend_payload),本档不依赖 SDK。
7
+ #
8
+ # 本档给什么:结构化元数据——title / author / abstract / 刊名 / 年份 /
9
+ # subjects / doi / citation_count,另带 unique_id(引用关系查询用)与
10
+ # is_content_accessible(该条是否真有全文)。
11
+ # 本档不给什么:证据句与页码——argo 条目放不下偏移量与页码,要证据句用技能 sciverse 的 sv.py;读正文要拿
12
+ # doc_id 走 GET /content,本档不做。
13
+ #
14
+ # 覆盖边界:外文(英/德/法)文献为主;中文只有海外中国学与开放获取刊物
15
+ # (Hanspub / MDPI / Asiatische Studien 之类),**不含 CNKI / 万方 / CSSCI
16
+ # 中文核心**,古籍与 PhilPapers 也不覆盖。
17
+ #
18
+ # 年份粒度:上游只给 publication_published_year(四位年份,无月日),下面
19
+ # published_at 映出来就是「2023」这样的串;本引擎也不在 argo 的
20
+ # TIME_CAPABLE_ENGINES 里,--since/--until 对它不生效。
21
+ #
22
+ # 计费:官方未公布单价,故声明 cost_tier: api(按调用计)而不写免费;在价格
23
+ # 与额度核实之前用 explicit_only 把它挡在域 combo 之外,避免「自动花钱却
24
+ # 算不出花了多少」。
25
+ #
26
+ # key 名与官方 SDK 对齐(SDK 还认 ~/.sciverse/credentials.json,走本档要写进
27
+ # 环境变量):ARGO_SCIVERSE_API_TOKEN 或 SCIVERSE_API_TOKEN。
28
+ #
29
+ # 实测(2026-10-28,带 token):engine_validate --stage all --admit 通过
30
+ # (health + quality,q=1.0);argo_search 有结果,url 由 doi 经 url_template
31
+ # 生成。无 token 时 health 门按设计 skipped,不算失败。
32
+ # 注意 published_at 是四位年份字符串(上游只给年,无月日)。
33
+ #
34
+ # 验证:
35
+ # python3 scripts/engine_validate.py --engine sciverse --stage all --admit --write-doc
36
+
37
+ engine_id: sciverse
38
+ type: http
39
+ enabled: true
40
+ explicit_only: true
41
+ url_kind: none
42
+ cost_tier: api
43
+ method: POST
44
+ url: https://api.sciverse.space/meta-search
45
+ timeout: 20
46
+ canary_query: "Kant transcendental deduction objectivity"
47
+ label: Sciverse(题录)
48
+ family: academic
49
+ priority: 56
50
+ required_env:
51
+ - [ARGO_SCIVERSE_API_TOKEN, SCIVERSE_API_TOKEN]
52
+
53
+ headers:
54
+ Authorization: Bearer {SCIVERSE_API_TOKEN}
55
+ Content-Type: application/json
56
+
57
+ body:
58
+ query: "{query}"
59
+ page: 1
60
+ page_size: 20
61
+ freshness_boost: MILD
62
+
63
+ output_map:
64
+ items: results
65
+ item_title: title
66
+ item_url: doi
67
+ item_summary: abstract
68
+ item_published_at: publication_published_year
69
+ item_upstream_authority: publication_venue_name_unified
70
+ item_upstream_score: citation_count
71
+ url_template: "https://doi.org/{doi}"
72
+
73
+ coverage: [academic, paper, english]
@@ -0,0 +1,32 @@
1
+ # skills_sh — 由 `argo engine add` 接入(2026-10-26)。
2
+ # 字段说明见 docs/ADDING_NEW_ENGINE.md;路由元数据(family/coverage/langs/
3
+ # domain_hints)由 engine_add 自动派生,可手工微调。
4
+ engine_id: skills_sh
5
+ type: skills_sh
6
+ enabled: true
7
+ cost_tier: free
8
+ label: skills.sh 技能目录
9
+ family: misc_vertical
10
+ priority: 51
11
+ qps: 2
12
+ period: minute
13
+ limit: null
14
+ cost_per_call: 0.0
15
+ cost_unit: free
16
+ timeout: 15
17
+ canary_query: git commit
18
+ coverage:
19
+ - skill
20
+ - developer
21
+ - tech
22
+ desc: skills.sh 技能目录(57k+,免认证,Vercel 官方安装遥测)
23
+ quality_queries:
24
+ - query: git commit
25
+ - query: code review
26
+ - query: pdf
27
+ langs:
28
+ - en
29
+ domain_hints:
30
+ - skill_search
31
+ - dsh_plugin_search
32
+ - rfc_search
@@ -1,14 +1,24 @@
1
1
  # SkillsMP — Agent Skills 聚合目录(skill 域跨生态技能索引,GET JSON,keyless)
2
2
  # 技能域的广覆盖目录源:独立索引 200 万+ 开源技能,支持语言/职业过滤,
3
3
  # 与 redskill(小红书生态 47650 技能本地缓存)互补不重复(不同上游、不同生态)。
4
- # 免费 REST API 无需密钥(bearerAuth 仅用于提额);sortBy=stars 按仓库热度排序,
5
- # stars 口径是源仓库星数非安装量,与 skills.sh 安装遥测、ClawHub 下载量互不可比。
6
- # 可选过滤参数(按需加进 extra_params):language(ISO 码,如 zh)、category、occupation。
4
+ # 免费 REST API 无需密钥(bearerAuth 仅用于提额);sortBy=stars 按仓库热度排序。
5
+ #
6
+ # 为什么是 L3(2026-10-26 从 L1 声明式改过来):
7
+ # 上游有 `stars`(源仓库星数)与 `githubUrl`(**能安装**的 GitHub 目录),
8
+ # 而 L1 的 output_map 只能把单字段映射成 summary——星数与「哪个地址能装」
9
+ # 这两个最有用的维度都透不出来。改 builder 后:摘要前缀带 ★ 星数,
10
+ # url 优先给 githubUrl(缺失时回落市场页 skillUrl)。
11
+ #
12
+ # 口径:stars 是**源仓库星数**(不是安装量),与 skills.sh 的 Vercel 遥测、
13
+ # explainx 的平台统计、ClawHub 的生态下载量互不可比,别混用。
14
+ # 可选过滤参数(builder 未接,按需加):language(ISO 码,如 zh)、category、occupation。
15
+ #
16
+ # 实现: scripts/engines_builders_skill.py::_build_skillsmp_engine
7
17
  # 验证:
8
18
  # python3 scripts/engine_validate.py --engine skillsmp --stage all --admit --write-doc
9
19
 
10
20
  engine_id: skillsmp
11
- type: http
21
+ type: skillsmp
12
22
  enabled: true
13
23
  cost_tier: free
14
24
  label: SkillsMP 技能目录
@@ -19,30 +29,22 @@ period: second
19
29
  limit: null
20
30
  cost_per_call: 0.0
21
31
  cost_unit: free
22
- method: GET
23
- url: https://skillsmp.com/api/v1/skills/search
24
32
  timeout: 15
25
33
  canary_query: "git commit"
26
34
  coverage:
27
35
  - skill
28
36
  - developer
29
37
  - tech
30
- desc: "SkillsMP Agent 技能聚合目录(200万+ 开源技能独立索引,免费 keyless REST API,stars 排序)"
31
- format: json
32
- query_param: q
33
- extra_params:
34
- limit: "{n}"
35
- sortBy: stars
38
+ desc: "SkillsMP Agent 技能聚合目录(200万+ 开源技能独立索引,免认证,带仓库星数与可安装的 GitHub 目录)"
39
+ # 可验证出处声明(L3 builder 自行拼字段,不读本表;保留它是为了把「这个源
40
+ # 必须给出能装的地址」写成声明,由 tests/test_skill_registry_contract.py 把守)。
41
+ # builder 侧对应实现:url 优先 githubUrl(缺失回落 skillUrl),摘要前缀带星数。
36
42
  output_map:
37
43
  items: data.skills
38
44
  item_title: name
39
45
  item_url: skillUrl
40
46
  item_summary: description
41
- # 可验证出处:githubUrl 指向该技能在上游仓里的**目录**(…/tree/main/.agents/
42
- # skills/xxx),是能核对、能安装的那个地址;skillUrl 只是市场页。
43
47
  item_upstream: githubUrl
44
- # updatedAt 是 epoch **秒**(ClawHub 同名字段是毫秒,差 1000 倍,由
45
- # engines_base._normalize_epoch 按量级归一成日期)。
46
48
  item_published_at: updatedAt
47
49
  quality_queries:
48
50
  - query: "git commit"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "argo-search",
3
- "version": "2.9.9",
4
- "description": "Argo 阿尔戈 — 统一搜索与证据核验。推荐 npx -y argo-search(npm 发布版)或 install.sh 安装。多语言路由、272 个源(235 个免密钥开箱可用)、影视/体育/金融等垂直源、19 个 MCP 工具(与 CLI 能力面对齐)。",
3
+ "version": "2.10.1",
4
+ "description": "Argo 阿尔戈 — 统一搜索与证据核验。推荐 npx -y argo-search(npm 发布版)或 install.sh 安装。多语言路由、284 个源(240 个免密钥开箱可用)、影视/体育/金融等垂直源、19 个 MCP 工具(与 CLI 能力面对齐)。",
5
5
  "keywords": [
6
6
  "mcp",
7
7
  "mcp-server",
@@ -53,6 +53,8 @@
53
53
  "docs/RELEASE_NOTES_v2.8.8.md",
54
54
  "docs/RELEASE_NOTES_v2.8.9.md",
55
55
  "docs/RELEASE_NOTES_v2.9.0.md",
56
+ "docs/RELEASE_NOTES_v2.10.1.md",
57
+ "docs/RELEASE_NOTES_v2.10.0.md",
56
58
  "docs/RELEASE_NOTES_v2.9.9.md",
57
59
  "docs/RELEASE_NOTES_v2.9.8.md",
58
60
  "docs/assets/",
@@ -5,7 +5,7 @@ DeepSeek Harness 插件:一行同时挂上 [Argo](https://github.com/taxueseek
5
5
  ## 安装
6
6
 
7
7
  ```bash
8
- dsh plugin --profile web add @taxueseek/argo-dsh # npm 发布版,已支持,当前 2.9.9
8
+ dsh plugin --profile web add @taxueseek/argo-dsh # npm 发布版,已支持,当前 2.10.0
9
9
  dsh plugin --profile web add "github:taxueseek/argo#main&path:packages/dsh-plugin" # GitHub main
10
10
  ```
11
11
 
@@ -102,7 +102,8 @@ argo 的 `deepseek_search` 引擎(官方 `api.deepseek.com/v1/tools/search`,
102
102
 
103
103
  | argo-dsh | DSH Harness | 说明 |
104
104
  |----------|-------------|------|
105
- | 2.9.9(当前) | 0.2.1-rc.2(当前,运行中) | 自带设置页(接入 / 工具 / API 密钥 / 研究 / 高级)新增路由观测卡片(getRouteHealth 只读本机 usage_log / route.jsonl 汇总最近路由决策,无日志不假装有数据)与工具推荐组合(按场景一键套用工具勾选,中英双语);双栈入口 `startActivation({provider, label, request, signal, delivery})`;rc.2 移除 `toolFilter` 启动期字段后由插件内 tool guard 阻止 worker 嵌套调用 `wide_research`;`wide_research` 端到端实测通过(planner → 2 worker → synthesis,passed=true / 14 sources) |
105
+ | 2.10.0(当前) | 0.2.1-rc.2(当前,运行中) | 与 2.9.9 同一套宿主适配;本版新增的技能索引/DSH 插件目录源与视频抓取都走既有工具面,插件侧无需改动 |
106
+ | 2.9.9(上一版,兼容) | 0.2.1-rc.2(当前,运行中) | 自带设置页(接入 / 工具 / API 密钥 / 研究 / 高级)新增路由观测卡片(getRouteHealth 只读本机 usage_log / route.jsonl 汇总最近路由决策,无日志不假装有数据)与工具推荐组合(按场景一键套用工具勾选,中英双语);双栈入口 `startActivation({provider, label, request, signal, delivery})`;rc.2 移除 `toolFilter` 启动期字段后由插件内 tool guard 阻止 worker 嵌套调用 `wide_research`;`wide_research` 端到端实测通过(planner → 2 worker → synthesis,passed=true / 14 sources) |
106
107
  | 2.9.7(上一版,兼容) | 0.2.1-alpha.1(实测,兼容) | 旧宿主走 `start(provider, request)` 分支,`toolFilter` 启动期字段仍认;该分支由插件单测覆盖,未在 alpha.x 上重跑端到端 |
107
108
  | 2.9.2 | 0.2.1-alpha.1(实测) | 上一轮适配验证基线;rc.2 的新入口与 tool guard 自 2.9.4 起进入 |
108
109
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taxueseek/argo-dsh",
3
- "version": "2.9.9",
3
+ "version": "2.10.1",
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",
@@ -0,0 +1,113 @@
1
+ // size-gate.test.js — dsh-plugin 单文件体积门禁(防「千行文件」复发)。
2
+ //
3
+ // ## 为什么要这道门
4
+ //
5
+ // Python 侧自 2026-09-22 起有 tests/test_module_size_gate.py(1000 行上限 +
6
+ // 祖父清单),这里补的是同一条门禁的 JS 对等物:2026-10-22 拆客户端时
7
+ // client.js 1,533 行,到 10-26 已涨到 1,599 行——两周 +66,且**没有任何
8
+ // 门禁会说话**。单文件超过千行后,改一处的定位成本(读完整条渲染链)比
9
+ // 拆模块的迁移成本涨得更快;趋势必须先钉住,再谈拆。
10
+ //
11
+ // ## 规则(与 Python 侧逐条对齐)
12
+ //
13
+ // 1. 上限 1000 行:dsh/ 下任何生产文件不得超过;
14
+ // 2. 祖父清单:拆不动的大文件显式登记「上限 = 登记时的行数」,只能减不能增;
15
+ // 3. 新增文件天然合规:不在清单里,直接吃 1000 上限;
16
+ // 4. 上限不得高于实际行数(清单不许虚高),每条必须写拆不开的理由。
17
+ //
18
+ // ## 清单怎么维护
19
+ //
20
+ // 拆走一块 → 把上限改成新的行数(或整条删掉,若已 ≤ 1000);想加功能又
21
+ // 超上限时,正解是拆模块,不是把数字往上调;真要上调,理由写进 reason。
22
+
23
+ import { test } from 'node:test'
24
+ import assert from 'node:assert/strict'
25
+ import { readFileSync, readdirSync } from 'node:fs'
26
+ import { dirname, join, relative } from 'node:path'
27
+ import { fileURLToPath } from 'node:url'
28
+
29
+ const PKG_ROOT = dirname(dirname(fileURLToPath(import.meta.url)))
30
+ const DSH_DIR = join(PKG_ROOT, 'dsh')
31
+
32
+ const HARD_LIMIT = 1000
33
+
34
+ // 路径 → [上限行数, 为什么不拆/拆到哪一步]
35
+ const GRANDFATHERED = new Map([
36
+ ['dsh/client.js', [
37
+ 1599,
38
+ 'web 设置面板单页(接入/工具/密钥/研究/高级五段 UI + 状态机);' +
39
+ '2026-10-26 面板升级后 1,533 → 1,599,功能与测试同批落地;' +
40
+ '拆分候选:把各段表单渲染抽成 render-* 模块,状态机留在本文件',
41
+ ]],
42
+ ])
43
+
44
+ function lineCount(file) {
45
+ const text = readFileSync(file, 'utf8')
46
+ const lines = text.split('\n')
47
+ // 与 wc -l / Python splitlines 同口径:以换行结尾时不算多一行
48
+ return text.endsWith('\n') ? lines.length - 1 : lines.length
49
+ }
50
+
51
+ function productionFiles() {
52
+ return readdirSync(DSH_DIR)
53
+ .filter((name) => name.endsWith('.js') || name.endsWith('.mjs'))
54
+ .sort()
55
+ .map((name) => join(DSH_DIR, name))
56
+ }
57
+
58
+ test('没有生产文件超过 1000 行且未登记', () => {
59
+ const offenders = []
60
+ for (const file of productionFiles()) {
61
+ const rel = relative(PKG_ROOT, file)
62
+ if (GRANDFATHERED.has(rel)) continue
63
+ const n = lineCount(file)
64
+ if (n > HARD_LIMIT) {
65
+ offenders.push(`${rel}: ${n} 行(上限 ${HARD_LIMIT})`)
66
+ }
67
+ }
68
+ assert.deepEqual(
69
+ offenders,
70
+ [],
71
+ '文件超过 1000 行且未登记。请先拆模块;确有必要登记时在 GRANDFATHERED 里写明理由:\n ' +
72
+ offenders.join('\n '),
73
+ )
74
+ })
75
+
76
+ test('祖父文件只能减不能增', () => {
77
+ const grown = []
78
+ for (const [rel, [ceiling]] of GRANDFATHERED) {
79
+ const file = join(PKG_ROOT, rel)
80
+ const n = lineCount(file)
81
+ if (n > ceiling) grown.push(`${rel}: ${n} 行 > 登记上限 ${ceiling}`)
82
+ }
83
+ assert.deepEqual(
84
+ grown,
85
+ [],
86
+ '祖父文件变大了。正解是拆模块并把上限调低;确要上调请在 GRANDFATHERED 里改数字并说明理由:\n ' +
87
+ grown.join('\n '),
88
+ )
89
+ })
90
+
91
+ test('祖父上限不得高于实际行数(清单不许虚高)', () => {
92
+ const inflated = []
93
+ for (const [rel, [ceiling]] of GRANDFATHERED) {
94
+ const n = lineCount(join(PKG_ROOT, rel))
95
+ if (ceiling > n) {
96
+ inflated.push(`${rel}: 上限 ${ceiling} > 实际 ${n}(请下调到 ${n})`)
97
+ }
98
+ }
99
+ assert.deepEqual(
100
+ inflated,
101
+ [],
102
+ '祖父清单的上限比实际行数高——把上限收到实际行数:\n ' + inflated.join('\n '),
103
+ )
104
+ })
105
+
106
+ test('每条祖父登记都必须写拆不开的理由', () => {
107
+ for (const [rel, [, reason]] of GRANDFATHERED) {
108
+ assert.ok(
109
+ typeof reason === 'string' && reason.trim().length >= 12,
110
+ `${rel} 的 reason 太短,写清楚卡在哪(数据表性质?缺测试?边界不清?)`,
111
+ )
112
+ }
113
+ })
@@ -106,7 +106,9 @@ class AdaptiveLearner:
106
106
  def __init__(self):
107
107
  self._lock = threading.Lock()
108
108
  self._local = threading.local()
109
- self._score_cache: dict[str, tuple[float, float]] = {} # engine -> (score, expires_at)
109
+ # (engine, domain, lang, purpose) -> (score, samples, expires_at)
110
+ self._score_cache: dict[
111
+ tuple[str, str, str, str], tuple[float, int, float]] = {}
110
112
  self._session_engines: set[str] = set()
111
113
  self._batch_depth = 0
112
114
  self._batch_dirty = False
@@ -239,8 +241,14 @@ class AdaptiveLearner:
239
241
  for _k in [k for k in self._score_cache if k[0] == engine]:
240
242
  self._score_cache.pop(_k, None)
241
243
 
242
- def _score_from_row(self, row) -> float:
243
- """把一条聚合行转成 0~1 推荐分(口径见 get_score)。"""
244
+ def _score_from_row(self, row, purpose: str = "daily") -> float:
245
+ """把一条聚合行转成 0~1 推荐分(口径见 get_score)。
246
+
247
+ `purpose="research"` 把延迟悬崖从 2s 抬到 8s:2s 是**日常档的等待
248
+ 政策**(慢源不该定义第一响应),不是质量判断。研究场景里同一台源
249
+ 4s 交出的扎实证据值得等;沿用 2s 悬崖会让「慢而高质」的源在深研
250
+ 排序里系统性输给「快而泛」的源——正是 2026-10-26 审查发现的偏差。
251
+ """
244
252
  total, judged, judged_ok, avg_latency, avg_cost, avg_q, sum_q, last_ts = row
245
253
  total = int(total or 0)
246
254
  judged = int(judged or 0)
@@ -252,7 +260,8 @@ class AdaptiveLearner:
252
260
  if judged == 0:
253
261
  return 0.5
254
262
  success_rate = (judged_ok or 0) / judged
255
- latency_factor = min(1.0, 2000.0 / max(avg_latency or 2000, 1))
263
+ latency_cap = 8000.0 if purpose == "research" else 2000.0
264
+ latency_factor = min(1.0, latency_cap / max(avg_latency or latency_cap, 1))
256
265
  cost_factor = max(0.3, 1.0 - (avg_cost or 0.0) * 10)
257
266
  return round(success_rate * latency_factor * cost_factor
258
267
  * quality_factor(avg_q, sum_q), 4)
@@ -283,7 +292,7 @@ class AdaptiveLearner:
283
292
  ).fetchone()
284
293
 
285
294
  def get_score(self, engine: str, domain: str | None = None,
286
- lang: str | None = None) -> float:
295
+ lang: str | None = None, purpose: str = "daily") -> float:
287
296
  """获取引擎的综合推荐分数(0.0 ~ 1.0)。
288
297
 
289
298
  **只按「有明确结果」的调用算成功率**(`empty=0`)。
@@ -302,28 +311,46 @@ class AdaptiveLearner:
302
311
  lang) 聚合出「桶分」,与全局分加权融合(桶样本 <3 时权重 0.3,≥3 时 0.5)。
303
312
  这让「引擎在 A 域强、B 域弱」可表达,新引擎也能在建议域里被更快识别。
304
313
  桶为空时回退全局分——旧调用方(不传 domain/lang)行为逐位不变。
314
+
315
+ `purpose`:daily(默认)沿用 2s 延迟悬崖;research 抬到 8s,见
316
+ `_score_from_row`。默认值保证旧调用方逐位不变。
317
+ """
318
+ return self.get_score_with_samples(
319
+ engine, domain, lang, purpose)[0]
320
+
321
+ def get_score_with_samples(self, engine: str, domain: str | None = None,
322
+ lang: str | None = None,
323
+ purpose: str = "daily") -> tuple[float, int]:
324
+ """同 get_score,额外返回有效样本数。
325
+
326
+ 选源层需要区分「0.5 分是因为没数据」与「0.5 分是因为确实平庸」:
327
+ 对无样本的源,实测先验应当做主,而不是被自适应默认分稀释。样本数
328
+ 取场景桶的 judged(桶为空时取全局 judged)。
305
329
  """
306
- key = (engine, domain or "", lang or "")
330
+ key = (engine, domain or "", lang or "", purpose)
307
331
  now = time.time()
308
332
  cached = self._score_cache.get(key)
309
- if cached and cached[1] > now:
310
- return cached[0]
333
+ if cached and cached[2] > now:
334
+ return cached[0], cached[1]
311
335
 
312
336
  with self._lock:
313
337
  cached = self._score_cache.get(key)
314
- if cached and cached[1] > now:
315
- return cached[0]
316
- score = self._score_from_row(self._global_row(engine))
338
+ if cached and cached[2] > now:
339
+ return cached[0], cached[1]
340
+ grow = self._global_row(engine)
341
+ score = self._score_from_row(grow, purpose)
342
+ samples = int((grow[1] if grow else 0) or 0)
317
343
  if domain or lang:
318
344
  brow = self._bucket_row(engine, domain or "", lang or "")
319
345
  b_judged = int(brow[1] or 0)
320
346
  if b_judged > 0:
321
- b_score = self._score_from_row(brow)
347
+ b_score = self._score_from_row(brow, purpose)
322
348
  w = 0.5 if b_judged >= 3 else 0.3
323
349
  score = round((1 - w) * score + w * b_score, 4)
350
+ samples = b_judged
324
351
 
325
- self._score_cache[key] = (score, now + self.SCORE_CACHE_TTL)
326
- return score
352
+ self._score_cache[key] = (score, samples, now + self.SCORE_CACHE_TTL)
353
+ return score, samples
327
354
 
328
355
  def get_ranking(self) -> list[tuple[str, float]]:
329
356
  """获取所有引擎的推荐排名(降序)。空结果的排除口径同 `get_score`。"""
@@ -29,7 +29,12 @@ def fetch(url: str, timeout: int = 30) -> str:
29
29
  # (http/https scheme + 非本机/内网目标),被拒即抛错而非跟随
30
30
  opener = urllib.request.build_opener(_SafeRedirectHandler)
31
31
  with opener.open(req, timeout=timeout) as r:
32
- return r.read().decode("utf-8", errors="ignore")
32
+ raw = r.read()
33
+ try:
34
+ from http_client import decode_response_body
35
+ return decode_response_body(raw, r.headers.get("Content-Type", ""))
36
+ except ImportError:
37
+ return raw.decode("utf-8", errors="ignore")
33
38
 
34
39
 
35
40
  class _SafeRedirectHandler(urllib.request.HTTPRedirectHandler):