argo-search 1.0.1 → 2.9.8
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/LICENSE +201 -21
- package/README.en.md +735 -0
- package/README.es.md +777 -0
- package/README.ja.md +777 -0
- package/README.ko.md +777 -0
- package/README.md +778 -320
- package/SKILL.md +135 -0
- package/assets/readme/hero.svg +121 -0
- package/assets/readme/made-with-beautify.svg +10 -0
- package/assets/readme/proof-routes.svg +73 -0
- package/assets/readme/why-better.svg +104 -0
- package/assets/readme/workflow.svg +83 -0
- package/backends/domain_profiles.json +2356 -96
- package/backends/engine_registry.yaml +3428 -503
- package/backends/query_synonyms_cn.json +35 -0
- package/backends/quota_profiles.json +2488 -160
- package/backends/source_types_cn.json +109 -0
- package/backends/text_lexicon.json +44 -0
- package/bin/argo +772 -0
- package/bin/argo.js +102 -39
- package/config.yaml +5139 -367
- package/cordis.patch.yml +21 -0
- package/data/countries.json +40 -0
- package/data/lang_matrix/lang_capability.json +842 -0
- package/data/lang_matrix/matrix_2026-09-10.json +11921 -0
- package/data/regions_cn.json +1 -0
- package/docs/ADDING_NEW_ENGINE.md +184 -0
- package/docs/ARGO_INTRO.md +124 -0
- package/docs/DATA_SOURCE_GAPS.md +81 -0
- package/docs/DESIGN_LOCAL_DATA_FUSION.md +90 -0
- package/docs/ENGINE_CATALOG.md +575 -0
- package/docs/MCP_SETUP.md +108 -0
- package/docs/PLATFORM_PATHS.md +111 -0
- package/docs/RELEASE_NOTES_v2.8.0.md +71 -0
- package/docs/RELEASE_NOTES_v2.8.2.md +63 -0
- package/docs/RELEASE_NOTES_v2.8.3.md +55 -0
- package/docs/RELEASE_NOTES_v2.8.4.md +79 -0
- package/docs/RELEASE_NOTES_v2.8.5.md +102 -0
- package/docs/RELEASE_NOTES_v2.8.6.md +66 -0
- package/docs/RELEASE_NOTES_v2.8.7.md +65 -0
- package/docs/RELEASE_NOTES_v2.8.8.md +67 -0
- package/docs/RELEASE_NOTES_v2.8.9.md +67 -0
- package/docs/RELEASE_NOTES_v2.9.0.md +64 -0
- package/docs/RELEASE_NOTES_v2.9.8.md +73 -0
- package/docs/SEARCH_ARCHIVE.md +115 -0
- package/docs/assets/architecture.svg +104 -0
- package/docs/assets/hero.svg +98 -0
- package/docs/engines/bangumi.md +27 -0
- package/docs/engines/biorxiv.md +27 -0
- package/docs/engines/clawhub.md +27 -0
- package/docs/engines/crt_sh.md +27 -0
- package/docs/engines/datacite.md +27 -0
- package/docs/engines/deps_dev.md +27 -0
- package/docs/engines/douban_movie.md +27 -0
- package/docs/engines/endoflife.md +27 -0
- package/docs/engines/flk_law.md +27 -0
- package/docs/engines/fxtwitter.md +27 -0
- package/docs/engines/google_news.md +27 -0
- package/docs/engines/gov_regulations.md +27 -0
- package/docs/engines/guqian.md +27 -0
- package/docs/engines/hackernews.md +27 -0
- package/docs/engines/iplant.md +27 -0
- package/docs/engines/keenable.md +27 -0
- package/docs/engines/met_museum.md +27 -0
- package/docs/engines/nasa_images.md +27 -0
- package/docs/engines/netease_music.md +27 -0
- package/docs/engines/npm.md +27 -0
- package/docs/engines/nvd.md +27 -0
- package/docs/engines/openreview.md +27 -0
- package/docs/engines/openstd.md +27 -0
- package/docs/engines/parallel_free.md +27 -0
- package/docs/engines/people_daily.md +27 -0
- package/docs/engines/realtime_index.md +27 -0
- package/docs/engines/sec_edgar.md +27 -0
- package/docs/engines/seltz.md +27 -0
- package/docs/engines/skillsmp.md +27 -0
- package/docs/engines/sspai.md +27 -0
- package/docs/engines/std_samr.md +27 -0
- package/docs/engines/train.md +27 -0
- package/docs/engines/un_comtrade.md +27 -0
- package/docs/engines/wikisource.md +27 -0
- package/docs/engines/zdic.md +27 -0
- package/docs/engines/zenodo.md +27 -0
- package/docs/engines/zhihu_hot_app.md +27 -0
- package/docs//344/270/272/344/273/200/344/271/210/351/200/211/346/213/251argo.md +176 -0
- package/engines/README.md +10 -0
- package/engines/_template_cli.yaml +39 -0
- package/engines/_template_http.yaml +37 -0
- package/engines/plugins/_template_plugin.py +50 -0
- package/engines/specs/_cisa_kev.yaml +54 -0
- package/engines/specs/_osv.yaml +63 -0
- package/engines/specs/aljazeera.yaml +43 -0
- package/engines/specs/antara.yaml +43 -0
- package/engines/specs/artic.yaml +20 -0
- package/engines/specs/aviation_weather.yaml +39 -0
- package/engines/specs/bangumi.yaml +21 -0
- package/engines/specs/biorxiv.yaml +24 -0
- package/engines/specs/carbon_intensity.yaml +32 -0
- package/engines/specs/cfets.yaml +41 -0
- package/engines/specs/cinii.yaml +44 -0
- package/engines/specs/clawhub.yaml +49 -0
- package/engines/specs/cleveland.yaml +19 -0
- package/engines/specs/cn_ai_news.yaml +43 -0
- package/engines/specs/core.yaml +35 -0
- package/engines/specs/crt_sh.yaml +38 -0
- package/engines/specs/ct24.yaml +43 -0
- package/engines/specs/datacite.yaml +27 -0
- package/engines/specs/datagov_uk.yaml +41 -0
- package/engines/specs/ddgs_images.yaml +45 -0
- package/engines/specs/deepseek_search.yaml +74 -0
- package/engines/specs/deezer.yaml +20 -0
- package/engines/specs/defillama.yaml +38 -0
- package/engines/specs/deps_dev.yaml +21 -0
- package/engines/specs/digup.yaml +36 -0
- package/engines/specs/doi.yaml +39 -0
- package/engines/specs/douban_movie.yaml +22 -0
- package/engines/specs/dw_news.yaml +47 -0
- package/engines/specs/egov_law.yaml +21 -0
- package/engines/specs/elpais.yaml +43 -0
- package/engines/specs/endoflife.yaml +21 -0
- package/engines/specs/energy_charts.yaml +21 -0
- package/engines/specs/factcheck_org.yaml +52 -0
- package/engines/specs/faz.yaml +43 -0
- package/engines/specs/federal_register.yaml +57 -0
- package/engines/specs/firecrawl.yaml +53 -0
- package/engines/specs/flk_law.yaml +24 -0
- package/engines/specs/folha.yaml +43 -0
- package/engines/specs/france24.yaml +44 -0
- package/engines/specs/full_fact.yaml +47 -0
- package/engines/specs/fxtwitter.yaml +36 -0
- package/engines/specs/gbfs_nyc.yaml +32 -0
- package/engines/specs/gdacs.yaml +21 -0
- package/engines/specs/gdelt.yaml +64 -0
- package/engines/specs/gleif.yaml +55 -0
- package/engines/specs/google_news.yaml +22 -0
- package/engines/specs/gov_regulations.yaml +38 -0
- package/engines/specs/guardian_rss.yaml +59 -0
- package/engines/specs/hkex.yaml +40 -0
- package/engines/specs/hurriyet.yaml +43 -0
- package/engines/specs/iplant.yaml +25 -0
- package/engines/specs/jikan.yaml +24 -0
- package/engines/specs/jolpica.yaml +20 -0
- package/engines/specs/k10plus.yaml +20 -0
- package/engines/specs/keenable.yaml +44 -0
- package/engines/specs/keenable_free.yaml +36 -0
- package/engines/specs/lefigaro.yaml +43 -0
- package/engines/specs/listenbrainz.yaml +19 -0
- package/engines/specs/matichon.yaml +43 -0
- package/engines/specs/met_museum.yaml +21 -0
- package/engines/specs/nasa_images.yaml +45 -0
- package/engines/specs/netease_music.yaml +38 -0
- package/engines/specs/nhk.yaml +43 -0
- package/engines/specs/nhtsa_vpic.yaml +20 -0
- package/engines/specs/noaa_swpc.yaml +20 -0
- package/engines/specs/nvd.yaml +38 -0
- package/engines/specs/obis.yaml +20 -0
- package/engines/specs/opencitations.yaml +52 -0
- package/engines/specs/openf1.yaml +21 -0
- package/engines/specs/openfoodfacts.yaml +45 -0
- package/engines/specs/openligadb.yaml +20 -0
- package/engines/specs/openreview.yaml +37 -0
- package/engines/specs/openstd.yaml +21 -0
- package/engines/specs/people_daily.yaml +22 -0
- package/engines/specs/realtime_index.yaml +34 -0
- package/engines/specs/ror.yaml +20 -0
- package/engines/specs/satnogs.yaml +20 -0
- package/engines/specs/sec_edgar.yaml +46 -0
- package/engines/specs/shfe.yaml +39 -0
- package/engines/specs/skillsmp.yaml +50 -0
- package/engines/specs/sogou_weixin_browser.yaml +30 -0
- package/engines/specs/soilgrids.yaml +25 -0
- package/engines/specs/sspai.yaml +36 -0
- package/engines/specs/stackexchange.yaml +46 -0
- package/engines/specs/std_samr.yaml +21 -0
- package/engines/specs/tass.yaml +43 -0
- package/engines/specs/tavily_free.yaml +56 -0
- package/engines/specs/tle_mirror.yaml +21 -0
- package/engines/specs/train.yaml +37 -0
- package/engines/specs/tvmaze.yaml +20 -0
- package/engines/specs/twitter_syndication.yaml +31 -0
- package/engines/specs/un_comtrade.yaml +23 -0
- package/engines/specs/unpaywall.yaml +54 -0
- package/engines/specs/vnpress.yaml +43 -0
- package/engines/specs/weather.yaml +32 -0
- package/engines/specs/who_don.yaml +21 -0
- package/engines/specs/who_gho.yaml +20 -0
- package/engines/specs/wikimedia_commons.yaml +34 -0
- package/engines/specs/wikisource.yaml +22 -0
- package/engines/specs/worms.yaml +19 -0
- package/engines/specs/x_trending.yaml +34 -0
- package/engines/specs/yna.yaml +43 -0
- package/engines/specs/ynet.yaml +43 -0
- package/engines/specs/yuanbao.yaml +93 -0
- package/engines/specs/zbmath.yaml +40 -0
- package/engines/specs/zdic.yaml +22 -0
- package/engines/specs/zenodo.yaml +27 -0
- package/engines/specs/zhihu_hot_app.yaml +35 -0
- package/mcp/clients.yaml +106 -0
- package/package.json +55 -12
- package/packages/dsh-plugin/README.md +152 -0
- package/packages/dsh-plugin/cordis.patch.yml +48 -0
- package/packages/dsh-plugin/dsh/client.js +1533 -0
- package/packages/dsh-plugin/dsh/diagnostics.js +54 -0
- package/packages/dsh-plugin/dsh/index.js +527 -0
- package/packages/dsh-plugin/dsh/native-tools.mjs +749 -0
- package/packages/dsh-plugin/dsh/runner.js +666 -0
- package/packages/dsh-plugin/dsh/wide-research.js +878 -0
- package/packages/dsh-plugin/package.json +38 -0
- package/packages/dsh-plugin/scripts/sync-local.sh +70 -0
- package/packages/dsh-plugin/test/client.test.js +406 -0
- package/packages/dsh-plugin/test/config.test.js +30 -0
- package/packages/dsh-plugin/test/diagnostics.test.js +28 -0
- package/packages/dsh-plugin/test/index.test.js +1382 -0
- package/references/query-templates.md +96 -0
- package/references/query-templates.yaml +118 -0
- package/scripts/ab_eval.py +219 -0
- package/scripts/ab_eval_p0p1.py +266 -0
- package/scripts/adaptive.py +294 -70
- package/scripts/answer.py +154 -0
- package/scripts/archive_run.py +591 -0
- package/scripts/argo_engine_registry.py +172 -0
- package/scripts/argo_paths.py +728 -0
- package/scripts/article.py +136 -0
- package/scripts/article_meta.py +131 -0
- package/scripts/arxiv_source.py +201 -0
- package/scripts/badcase_ledger.py +252 -0
- package/scripts/batch_probe.py +241 -0
- package/scripts/benchmark.py +19 -0
- package/scripts/bounded_run.py +144 -0
- package/scripts/browser_auth.py +323 -0
- package/scripts/budget.py +247 -0
- package/scripts/budget_cli.py +93 -0
- package/scripts/build_release_assets.sh +65 -0
- package/scripts/burstiness_detector.py +147 -0
- package/scripts/cache.py +1066 -67
- package/scripts/cache_guard.py +271 -0
- package/scripts/cache_key_vdom.py +56 -0
- package/scripts/cache_similarity.py +170 -0
- package/scripts/caliber_isolation.py +195 -0
- package/scripts/calibrate_lowquality.py +210 -0
- package/scripts/candidate_envelope.py +366 -0
- package/scripts/chrome_cdp.py +871 -0
- package/scripts/ci_drift_gate.py +90 -0
- package/scripts/circuit_breaker.py +389 -0
- package/scripts/citations.py +334 -0
- package/scripts/cite_cli.py +59 -0
- package/scripts/cjk_tokens.py +95 -0
- package/scripts/clarify.py +47 -24
- package/scripts/cli_io.py +240 -0
- package/scripts/config.py +683 -45
- package/scripts/config_cache.py +402 -0
- package/scripts/conn_pool.py +220 -0
- package/scripts/content_boundary.py +46 -0
- package/scripts/content_security.py +685 -0
- package/scripts/content_signals.py +751 -0
- package/scripts/crawl.py +74 -35
- package/scripts/cross_lingual_trace.py +293 -0
- package/scripts/daemon.py +866 -0
- package/scripts/digup_bridge.py +214 -0
- package/scripts/dispatch_result.py +98 -0
- package/scripts/engine_admission.py +366 -0
- package/scripts/engine_dispatch.py +982 -0
- package/scripts/engine_env.py +539 -0
- package/scripts/engine_failure.py +411 -0
- package/scripts/engine_families.py +738 -0
- package/scripts/engine_policy.py +218 -0
- package/scripts/engine_requires.py +190 -0
- package/scripts/engine_status.py +322 -0
- package/scripts/engine_validate.py +638 -0
- package/scripts/engines.py +799 -294
- package/scripts/engines_base.py +1521 -0
- package/scripts/engines_builders.py +310 -0
- package/scripts/engines_builders_batch10.py +204 -0
- package/scripts/engines_builders_batch11.py +174 -0
- package/scripts/engines_builders_batch12.py +103 -0
- package/scripts/engines_builders_batch13.py +340 -0
- package/scripts/engines_builders_batch14.py +656 -0
- package/scripts/engines_builders_batch15.py +249 -0
- package/scripts/engines_builders_batch9.py +1468 -0
- package/scripts/engines_builders_cn.py +2283 -0
- package/scripts/engines_builders_data.py +2923 -0
- package/scripts/engines_builders_data_macro.py +775 -0
- package/scripts/engines_builders_feeds.py +255 -0
- package/scripts/engines_builders_intl.py +1239 -0
- package/scripts/engines_builders_keyless.py +111 -0
- package/scripts/engines_builders_search.py +440 -0
- package/scripts/engines_builders_tech.py +1359 -0
- package/scripts/evidence.py +620 -166
- package/scripts/evidence_loop.py +624 -0
- package/scripts/evidence_tier.py +298 -0
- package/scripts/except_sets.py +25 -0
- package/scripts/extract.py +55 -16
- package/scripts/fact_align.py +207 -0
- package/scripts/fact_crosscheck.py +230 -0
- package/scripts/fetch.py +25 -12
- package/scripts/fetch_browser.py +87 -0
- package/scripts/fetch_jsrun.py +122 -0
- package/scripts/fetch_quality.py +225 -0
- package/scripts/fetch_render_tinyfish.py +117 -0
- package/scripts/fetch_v3.py +1804 -0
- package/scripts/focus_extract.py +350 -0
- package/scripts/fulltext_store.py +169 -0
- package/scripts/fxtwitter_api.py +325 -0
- package/scripts/gen_engine_catalog.py +364 -0
- package/scripts/gen_native_tools.py +91 -0
- package/scripts/gen_routing_snapshot.py +195 -0
- package/scripts/health_check.py +140 -402
- package/scripts/health_probe.py +23 -8
- package/scripts/hot_state.py +134 -0
- package/scripts/http_client.py +1053 -0
- package/scripts/image_ops.py +430 -0
- package/scripts/image_vision/vision_probe.swift +126 -0
- package/scripts/install.ps1 +166 -0
- package/scripts/install.sh +221 -0
- package/scripts/job.py +1186 -0
- package/scripts/jump_resolver.py +235 -0
- package/scripts/lang_capability.py +150 -0
- package/scripts/lang_detect.py +289 -0
- package/scripts/lang_matrix_probe.py +329 -0
- package/scripts/lang_pref.py +311 -0
- package/scripts/link_source.py +340 -0
- package/scripts/local_image.py +970 -0
- package/scripts/local_seek.py +402 -0
- package/scripts/macro_countries.py +97 -0
- package/scripts/matrix_search_eval.py +1187 -0
- package/scripts/mcp_compact.py +234 -0
- package/scripts/mcp_diag.py +8 -3
- package/scripts/mcp_handlers.py +492 -0
- package/scripts/mcp_handlers_surface.py +157 -0
- package/scripts/mcp_launch.sh +124 -0
- package/scripts/mcp_local.py +241 -0
- package/scripts/mcp_server.py +125 -419
- package/scripts/mcp_setup.py +431 -0
- package/scripts/mcp_tools.py +331 -0
- package/scripts/mcp_transport.py +191 -0
- package/scripts/mcp_warm.py +127 -0
- package/scripts/min_version_scan.py +335 -0
- package/scripts/net_proxy.py +258 -0
- package/scripts/network_aware.py +152 -0
- package/scripts/output_transparency.py +200 -0
- package/scripts/paid_policy.py +98 -0
- package/scripts/paper.py +274 -0
- package/scripts/pdf_extract.py +518 -0
- package/scripts/phrase_filter.py +66 -0
- package/scripts/plan.py +422 -0
- package/scripts/postprocess_signals.py +150 -0
- package/scripts/pre-commit +48 -0
- package/scripts/query_enhance.py +157 -0
- package/scripts/query_operators.py +196 -0
- package/scripts/query_rewriter.py +116 -7
- package/scripts/query_signals.py +300 -0
- package/scripts/query_templates.py +167 -0
- package/scripts/query_understanding.py +411 -0
- package/scripts/query_variants.py +298 -0
- package/scripts/quota.py +633 -76
- package/scripts/rank_signals.py +775 -0
- package/scripts/ranking_eval.py +319 -0
- package/scripts/readability_extract.py +433 -0
- package/scripts/recompute.py +415 -0
- package/scripts/recovery.py +616 -0
- package/scripts/recovery_l0.py +160 -0
- package/scripts/recovery_runner.py +150 -0
- package/scripts/redskill/redskill_engine.py +332 -0
- package/scripts/regression_p0p1.py +318 -0
- package/scripts/replay_eval.py +658 -0
- package/scripts/rerank_tfidf.py +225 -0
- package/scripts/research.py +607 -403
- package/scripts/research_cli.py +361 -0
- package/scripts/research_dossier.py +492 -0
- package/scripts/research_expand.py +169 -0
- package/scripts/research_gates.py +272 -0
- package/scripts/research_report.py +209 -0
- package/scripts/research_strategy.py +37 -0
- package/scripts/research_work_packages.py +195 -0
- package/scripts/result_lang.py +311 -0
- package/scripts/retry_policy.py +76 -0
- package/scripts/robots_guard.py +259 -0
- package/scripts/route.py +921 -254
- package/scripts/route_bangs.py +40 -0
- package/scripts/route_cache.py +243 -0
- package/scripts/route_combo.py +917 -0
- package/scripts/route_domains.py +341 -0
- package/scripts/route_lang.py +605 -0
- package/scripts/route_log.py +63 -0
- package/scripts/route_policy.py +250 -0
- package/scripts/rrf_classic.py +66 -0
- package/scripts/screenshot.py +73 -0
- package/scripts/search.py +886 -406
- package/scripts/search_attribution.py +185 -0
- package/scripts/search_benchmark.py +407 -0
- package/scripts/search_cli.py +640 -0
- package/scripts/search_entry.py +395 -0
- package/scripts/search_output.py +690 -0
- package/scripts/search_pipeline.py +926 -0
- package/scripts/search_rank.py +991 -0
- package/scripts/search_types.py +129 -16
- package/scripts/seek_locator.py +68 -0
- package/scripts/semantic_evidence.py +391 -0
- package/scripts/serp_guard.py +336 -0
- package/scripts/serp_kill_log.py +74 -0
- package/scripts/single_flight.py +120 -0
- package/scripts/social_engines/__init__.py +10 -0
- package/scripts/social_engines/bilibili_engine.py +131 -0
- package/scripts/social_engines/hackernews_engine.py +113 -0
- package/scripts/social_engines/reddit_engine.py +172 -0
- package/scripts/social_engines/twitter_engine.py +397 -0
- package/scripts/social_engines/v2ex_engine.py +101 -0
- package/scripts/social_engines/weibo_engine.py +128 -0
- package/scripts/social_engines/xiaohongshu_engine.py +137 -0
- package/scripts/social_engines/zhihu_engine.py +139 -0
- package/scripts/social_research.py +201 -0
- package/scripts/sogou_weixin_browser.py +318 -0
- package/scripts/source_ledger.py +249 -0
- package/scripts/stage_timing.py +58 -0
- package/scripts/stats_cli.py +107 -0
- package/scripts/straggler_policy.py +60 -0
- package/scripts/stylometry_detector.py +231 -0
- package/scripts/sync_backends.py +353 -0
- package/scripts/sync_installs.py +29 -0
- package/scripts/template_cli.py +127 -0
- package/scripts/text_lexicon.py +72 -0
- package/scripts/tfidf_router.py +109 -37
- package/scripts/time_utils.py +233 -0
- package/scripts/topic_research_profiles.py +643 -0
- package/scripts/train.py +737 -0
- package/scripts/tweet.py +596 -0
- package/scripts/url_canon.py +217 -0
- package/scripts/url_optimize.py +56 -0
- package/scripts/url_safety.py +236 -0
- package/scripts/usage_log.py +116 -0
- package/scripts/usage_log_clean.py +113 -0
- package/scripts/v2ex_nodes.py +311 -0
- package/scripts/variant_recall.py +188 -0
- package/scripts/watch.py +205 -0
- package/scripts/wechat_article.py +258 -0
- package/scripts/wide_research.py +447 -0
- package/scripts/wx.py +349 -0
- package/scripts/x_article_fetch.py +141 -0
- package/scripts/x_search.py +234 -0
- package/scripts/x_trending.py +189 -0
- package/scripts/yaml_load.py +67 -0
- package/scripts/zhihu_quota.py +139 -0
- package/sub-skills/ego-search/SKILL.md +253 -0
- package/sub-skills/ego-search/scripts/ego_search.py +800 -0
- package/sub-skills/ego-search/scripts/merge.py +226 -0
- package/sub-skills/ego-search/scripts/quality.py +64 -0
- package/sub-skills/ego-search/scripts/runtime.py +172 -0
- package/sub-skills/ego-search/scripts/safety.py +109 -0
- package/sub-skills/ego-search/scripts/serp_spec.py +109 -0
- package/sub-skills/ego-search/scripts/webbridge_adapter.py +374 -0
- package/sub-skills/js-run/SKILL.md +67 -0
- package/sub-skills/js-run/scripts/jsrun.py +112 -0
- package/sub-skills/js-run/scripts/shim.js +188 -0
- package/sub-skills/local-search/SKILL.md +50 -53
- package/sub-skills/local-search/bm25.py +186 -0
- package/sub-skills/local-search/cli_runner.py +331 -0
- package/sub-skills/local-search/config.yaml +152 -55
- package/sub-skills/local-search/engine_registry.py +91 -26
- package/sub-skills/local-search/{health_check.py → local_health_check.py} +140 -10
- package/sub-skills/local-search/local_search_adapter.py +13 -2
- package/sub-skills/local-search/parse_maps.yaml +40 -42
- package/sub-skills/local-search/parsers.py +328 -0
- package/sub-skills/local-search/search_v3.py +716 -242
- package/sub-skills/local-search/smart_router.py +47 -7
- package/sub-skills/local-seek/SKILL.md +110 -0
- package/sub-skills/local-seek/config/domains.yaml +20 -0
- package/sub-skills/local-seek/scripts/eval_rank.py +216 -0
- package/sub-skills/local-seek/scripts/eval_seek.py +224 -0
- package/sub-skills/local-seek/scripts/seek.py +1465 -0
- package/sub-skills/local-seek/scripts/seek_frecency.py +126 -0
- package/sub-skills/local-seek/scripts/seek_fts.py +430 -0
- package/sub-skills/local-seek/scripts/seek_rank.py +197 -0
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""research_gates.py — dossier 可判定检查。
|
|
3
|
+
|
|
4
|
+
topic profile 的 quality_gates 字符串是给 Agent 的自检提示。
|
|
5
|
+
这里的谓词决定 conclusion_cap,过不了就降级,不打印空勾选充数。
|
|
6
|
+
|
|
7
|
+
2026-09-27 新增三类门控(方案 C):
|
|
8
|
+
- 来源多样性:单一域名占比过高时降级(仿 CDQ 的站点级信号)
|
|
9
|
+
- 时效性:过时内容占比过高时降级(仿 Google E-E-A-T 的时效性信号)
|
|
10
|
+
- 事实一致性:多来源事实冲突时降级(仿 Fact-Check-X 的核验流程)
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import re
|
|
16
|
+
from collections import Counter
|
|
17
|
+
from typing import Any
|
|
18
|
+
from urllib.parse import urlparse
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _host_of(url: str) -> str:
|
|
22
|
+
"""取规范化 host(www 折叠为裸域)。"""
|
|
23
|
+
if not url:
|
|
24
|
+
return ""
|
|
25
|
+
try:
|
|
26
|
+
host = urlparse(url).netloc.lower().split(":", 1)[0]
|
|
27
|
+
except Exception:
|
|
28
|
+
return ""
|
|
29
|
+
return host[4:] if host.startswith("www.") else host
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _check_source_diversity(sources: list[dict[str, Any]]) -> dict[str, Any]:
|
|
33
|
+
"""来源多样性门控:单一域名占比过高时降级。
|
|
34
|
+
|
|
35
|
+
仿 CDQ(Content Quality Score)的站点级信号:深度研究可能从同一域名
|
|
36
|
+
获取多条来源(如知乎专栏的多篇文章),这些来源看似独立,实则同源。
|
|
37
|
+
|
|
38
|
+
判据:单一域名占比 > 60% 且总来源数 >= 3 时触发。
|
|
39
|
+
"""
|
|
40
|
+
hosts = []
|
|
41
|
+
for s in sources:
|
|
42
|
+
if not isinstance(s, dict):
|
|
43
|
+
continue
|
|
44
|
+
host = _host_of(s.get("url") or "")
|
|
45
|
+
if host:
|
|
46
|
+
hosts.append(host)
|
|
47
|
+
if len(hosts) < 3:
|
|
48
|
+
return {"triggered": False, "max_share": 0.0, "max_host": ""}
|
|
49
|
+
counts = Counter(hosts)
|
|
50
|
+
max_host, max_count = counts.most_common(1)[0]
|
|
51
|
+
share = max_count / len(hosts)
|
|
52
|
+
return {
|
|
53
|
+
"triggered": share > 0.6,
|
|
54
|
+
"max_share": round(share, 3),
|
|
55
|
+
"max_host": max_host,
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _check_freshness(sources: list[dict[str, Any]]) -> dict[str, Any]:
|
|
60
|
+
"""时效性门控:过时内容占比过高时降级。
|
|
61
|
+
|
|
62
|
+
仿 Google E-E-A-T 的时效性信号:深度研究可能引用过时内容(如 2020 年的
|
|
63
|
+
「最新推荐」),影响结论可靠性。
|
|
64
|
+
|
|
65
|
+
判据:过时内容(> 365 天)占比 > 50% 且总来源数 >= 2 时触发。
|
|
66
|
+
"""
|
|
67
|
+
now_ts = __import__("time").time()
|
|
68
|
+
stale_count = 0
|
|
69
|
+
total = 0
|
|
70
|
+
for s in sources:
|
|
71
|
+
if not isinstance(s, dict):
|
|
72
|
+
continue
|
|
73
|
+
total += 1
|
|
74
|
+
# 尝试从多个字段获取时间
|
|
75
|
+
date_str = (s.get("published_time") or s.get("modified_time")
|
|
76
|
+
or s.get("date") or "")
|
|
77
|
+
if not date_str:
|
|
78
|
+
continue
|
|
79
|
+
try:
|
|
80
|
+
from datetime import datetime, timezone
|
|
81
|
+
# 尝试 ISO 格式
|
|
82
|
+
dt = datetime.fromisoformat(date_str.replace("Z", "+00:00"))
|
|
83
|
+
age_days = (datetime.now(timezone.utc) - dt).days
|
|
84
|
+
if age_days > 365:
|
|
85
|
+
stale_count += 1
|
|
86
|
+
except Exception:
|
|
87
|
+
continue
|
|
88
|
+
if total < 2:
|
|
89
|
+
return {"triggered": False, "stale_ratio": 0.0, "stale_count": 0}
|
|
90
|
+
ratio = stale_count / total
|
|
91
|
+
return {
|
|
92
|
+
"triggered": ratio > 0.5,
|
|
93
|
+
"stale_ratio": round(ratio, 3),
|
|
94
|
+
"stale_count": stale_count,
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _check_fact_consistency(dossier: dict[str, Any]) -> dict[str, Any]:
|
|
99
|
+
"""事实一致性门控:多来源事实冲突时降级。
|
|
100
|
+
|
|
101
|
+
仿 Fact-Check-X 的核验流程:各方答案汇总 → 聚合 → 权威核验 → 最终答案。
|
|
102
|
+
这里只做粗粒度检测:fact_conflicts 非空时降级。
|
|
103
|
+
|
|
104
|
+
判据:fact_conflicts 非空且冲突数 >= 2 时触发。
|
|
105
|
+
"""
|
|
106
|
+
fa = dossier.get("fact_alignment") or {}
|
|
107
|
+
conflicts = fa.get("fact_conflicts") or []
|
|
108
|
+
return {
|
|
109
|
+
"triggered": len(conflicts) >= 2,
|
|
110
|
+
"conflict_count": len(conflicts),
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def evaluate_dossier_gates(dossier: dict[str, Any]) -> dict[str, Any]:
|
|
115
|
+
"""对取证包跑可判定谓词。返回 passed / conclusion_cap / failures / warnings。"""
|
|
116
|
+
failures: list[dict[str, Any]] = []
|
|
117
|
+
warnings: list[dict[str, Any]] = []
|
|
118
|
+
|
|
119
|
+
sources = dossier.get("sources") or dossier.get("citations") or []
|
|
120
|
+
url_count = sum(
|
|
121
|
+
1 for s in sources if isinstance(s, dict) and s.get("url")
|
|
122
|
+
)
|
|
123
|
+
if url_count == 0:
|
|
124
|
+
failures.append({
|
|
125
|
+
"id": "no_sources",
|
|
126
|
+
"detail": "可用 URL 为 0",
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
uncovered = [
|
|
130
|
+
cm for cm in (dossier.get("coverage_map") or [])
|
|
131
|
+
if isinstance(cm, dict) and cm.get("status") == "NOT_COVERED"
|
|
132
|
+
]
|
|
133
|
+
if uncovered:
|
|
134
|
+
failures.append({
|
|
135
|
+
"id": "uncovered_dimensions",
|
|
136
|
+
"detail": "、".join(
|
|
137
|
+
str(cm.get("dimension") or cm.get("sub_query") or "?")
|
|
138
|
+
for cm in uncovered[:8]
|
|
139
|
+
),
|
|
140
|
+
"count": len(uncovered),
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
fetch_required = bool(dossier.get("fetch_required"))
|
|
144
|
+
# 「跑过 --verify」≠「核验成功」。dossier["verify"] 是 verify_results 的返回
|
|
145
|
+
# dict,而 research_cli 在 --verify 分支里**无条件**赋值它——全部 fetch 失败
|
|
146
|
+
# 时它仍是 {verified: [], revision_summary: {...}, ...},真值判据为真。
|
|
147
|
+
# 于是「高后果取证尚未核验」这道门在「核验全失败」时反而放行,正是它要拦的
|
|
148
|
+
# 场景。判据取 verified 列表是否非空(那是真正拿到正文的那些 URL)。
|
|
149
|
+
verify_report = dossier.get("verify") or {}
|
|
150
|
+
verified = bool(verify_report.get("verified")) if isinstance(verify_report, dict) \
|
|
151
|
+
else bool(verify_report)
|
|
152
|
+
if not verified:
|
|
153
|
+
el = dossier.get("evidence_loop") or {}
|
|
154
|
+
verified = int(el.get("verified_count") or 0) > 0
|
|
155
|
+
if fetch_required and not verified:
|
|
156
|
+
failures.append({
|
|
157
|
+
"id": "fetch_required_unverified",
|
|
158
|
+
"detail": "高后果取证尚未 --verify / fetch",
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
fa = dossier.get("fact_alignment") or {}
|
|
162
|
+
conflicts = fa.get("fact_conflicts") or []
|
|
163
|
+
if conflicts:
|
|
164
|
+
warnings.append({
|
|
165
|
+
"id": "fact_conflicts",
|
|
166
|
+
"detail": f"{len(conflicts)} 组事实冲突未校准",
|
|
167
|
+
"count": len(conflicts),
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
# ── 方案 C:三类新门控 ──────────────────────────────────────────────
|
|
171
|
+
# 1) 来源多样性门控(仿 CDQ 站点级信号)
|
|
172
|
+
diversity = _check_source_diversity(sources)
|
|
173
|
+
if diversity["triggered"]:
|
|
174
|
+
warnings.append({
|
|
175
|
+
"id": "low_source_diversity",
|
|
176
|
+
"detail": (
|
|
177
|
+
f"单一域名 {diversity['max_host']} 占比 "
|
|
178
|
+
f"{diversity['max_share']:.0%},来源多样性不足"
|
|
179
|
+
),
|
|
180
|
+
"max_host": diversity["max_host"],
|
|
181
|
+
"max_share": diversity["max_share"],
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
# 2) 时效性门控(仿 Google E-E-A-T 时效性信号)
|
|
185
|
+
freshness = _check_freshness(sources)
|
|
186
|
+
if freshness["triggered"]:
|
|
187
|
+
warnings.append({
|
|
188
|
+
"id": "stale_content_heavy",
|
|
189
|
+
"detail": (
|
|
190
|
+
f"过时内容占比 {freshness['stale_ratio']:.0%}"
|
|
191
|
+
f"({freshness['stale_count']} 条),时效性不足"
|
|
192
|
+
),
|
|
193
|
+
"stale_ratio": freshness["stale_ratio"],
|
|
194
|
+
"stale_count": freshness["stale_count"],
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
# 3) 事实一致性门控(仿 Fact-Check-X 核验流程)
|
|
198
|
+
consistency = _check_fact_consistency(dossier)
|
|
199
|
+
if consistency["triggered"]:
|
|
200
|
+
warnings.append({
|
|
201
|
+
"id": "fact_consistency_low",
|
|
202
|
+
"detail": (
|
|
203
|
+
f"{consistency['conflict_count']} 组事实冲突未校准,"
|
|
204
|
+
f"结论可靠性不足"
|
|
205
|
+
),
|
|
206
|
+
"conflict_count": consistency["conflict_count"],
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
# ── recompute 检查(P0-2):可复算完整链路 ──
|
|
210
|
+
rec = dossier.get("recomputed_values") or []
|
|
211
|
+
# 1) 声明可复算但未执行(授权检查默认拒绝拦下)→ 结论上限 medium
|
|
212
|
+
if dossier.get("recompute_expected") and not rec:
|
|
213
|
+
warnings.append({
|
|
214
|
+
"id": "recompute_skipped",
|
|
215
|
+
"detail": "工作包声明 recompute 但未运行(未授权或执行失败)",
|
|
216
|
+
})
|
|
217
|
+
# 2) 重算值与检索数字无交集 → 提示冲突(以重算为准,需人工核对)
|
|
218
|
+
elif rec:
|
|
219
|
+
snippet_nums: set[float] = set()
|
|
220
|
+
try:
|
|
221
|
+
from recompute import extract_values as _extract
|
|
222
|
+
except ImportError:
|
|
223
|
+
_extract = None
|
|
224
|
+
for s in (dossier.get("sources") or []):
|
|
225
|
+
if not isinstance(s, dict):
|
|
226
|
+
continue
|
|
227
|
+
text = f"{s.get('title') or ''} {s.get('snippet') or ''}"
|
|
228
|
+
if _extract is not None:
|
|
229
|
+
snippet_nums.update(_extract(text))
|
|
230
|
+
for rv in rec:
|
|
231
|
+
if not rv.get("ok") or not rv.get("values"):
|
|
232
|
+
continue
|
|
233
|
+
if snippet_nums and not (
|
|
234
|
+
set(rv["values"]) & snippet_nums
|
|
235
|
+
):
|
|
236
|
+
warnings.append({
|
|
237
|
+
"id": "recompute_conflict",
|
|
238
|
+
"detail": (
|
|
239
|
+
f"重算值 {rv['values']} 与检索来源数字无交集"
|
|
240
|
+
f"(包 {rv.get('package_id') or '?'}),以重算为准"
|
|
241
|
+
),
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
grades = dossier.get("source_grades") or {}
|
|
245
|
+
if grades:
|
|
246
|
+
leads = dossier.get("source_leads") or dossier.get("verification_records") or []
|
|
247
|
+
has_primary = any(
|
|
248
|
+
isinstance(r, dict) and r.get("evidence_tier") == "primary"
|
|
249
|
+
for r in leads
|
|
250
|
+
)
|
|
251
|
+
# 本地一手数据文件(file_inputs 入账)计为一手命中:用户提供原始
|
|
252
|
+
# 数据时,「零一手来源」不成立(原始数据即一手),避免假阴性。
|
|
253
|
+
local_primary = bool(dossier.get("local_sources"))
|
|
254
|
+
if not has_primary and not local_primary:
|
|
255
|
+
warnings.append({
|
|
256
|
+
"id": "no_primary_sources",
|
|
257
|
+
"detail": "有 source_grades 但零一手命中",
|
|
258
|
+
})
|
|
259
|
+
|
|
260
|
+
if failures:
|
|
261
|
+
cap = "low"
|
|
262
|
+
elif warnings:
|
|
263
|
+
cap = "medium"
|
|
264
|
+
else:
|
|
265
|
+
cap = "high"
|
|
266
|
+
|
|
267
|
+
return {
|
|
268
|
+
"passed": not failures,
|
|
269
|
+
"conclusion_cap": cap,
|
|
270
|
+
"failures": failures,
|
|
271
|
+
"warnings": warnings,
|
|
272
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
research_report.py — 深度研究报告打印(从 research.py 拆分)
|
|
4
|
+
|
|
5
|
+
承载 _print_deep_report:终端渲染深度研究报告。
|
|
6
|
+
从 research.py 拆分以控制文件规模(code-review:单文件 <1k 行)。
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def print_deep_report(report: dict):
|
|
15
|
+
"""打印深度研究报告:正文用 [n] 标注,链接统一沉底「相关信源」。"""
|
|
16
|
+
elapsed_s = report.get("elapsed_ms", 0) / 1000
|
|
17
|
+
sub_count = report.get("sub_query_count", len(report.get("sub_findings", [])))
|
|
18
|
+
total_sources = report.get("total_sources", 0)
|
|
19
|
+
citations = report.get("citations") or []
|
|
20
|
+
sources = report.get("sources") or []
|
|
21
|
+
if not sources and citations:
|
|
22
|
+
sources = [
|
|
23
|
+
{
|
|
24
|
+
"ref": c.get("ref") or i + 1,
|
|
25
|
+
"title": c.get("title"),
|
|
26
|
+
"url": c.get("url"),
|
|
27
|
+
"engine": c.get("source"),
|
|
28
|
+
}
|
|
29
|
+
for i, c in enumerate(citations)
|
|
30
|
+
if isinstance(c, dict) and c.get("url")
|
|
31
|
+
]
|
|
32
|
+
citations_count = len(citations) or len(sources)
|
|
33
|
+
|
|
34
|
+
print(f"\n{'='*60}")
|
|
35
|
+
print("=== 深度研究取证包 ===")
|
|
36
|
+
print(f"{'='*60}")
|
|
37
|
+
print(f"查询:{report.get('query', '')}")
|
|
38
|
+
if report.get("kind"):
|
|
39
|
+
cap = report.get("conclusion_cap") or ""
|
|
40
|
+
print(f"产物:{report.get('kind')} | 结论上限:{cap or '—'}")
|
|
41
|
+
stages = report.get("work_package_stages") or []
|
|
42
|
+
if stages:
|
|
43
|
+
print("工作包阶段:" + " → ".join("+".join(s) for s in stages))
|
|
44
|
+
if report.get("rewritten_query"):
|
|
45
|
+
rq = report["rewritten_query"]
|
|
46
|
+
print(f"改写:{rq.get('original', '')} → {rq.get('rewritten', '')}(置信度 {rq.get('confidence', 0):.2f})")
|
|
47
|
+
print(f"子查询:{sub_count} 个 | 来源:{total_sources} 个 | 引用:{citations_count} 个 | 耗时:{elapsed_s:.1f}s")
|
|
48
|
+
if report.get("archive"):
|
|
49
|
+
print(f"归档:{report['archive'].get('run_dir', '')}")
|
|
50
|
+
print()
|
|
51
|
+
|
|
52
|
+
# 关键发现(链接用 [n],不在正文刷 URL)
|
|
53
|
+
print("## 关键发现")
|
|
54
|
+
print()
|
|
55
|
+
for i, kf in enumerate(report.get("key_findings", []), 1):
|
|
56
|
+
aspect = kf.get("aspect", kf.get("sub_query", ""))
|
|
57
|
+
refs = kf.get("citation_refs") or []
|
|
58
|
+
ref_s = "".join(f"[{r}]" for r in refs) if refs else ""
|
|
59
|
+
print(f"### {i}. {aspect} {ref_s}".rstrip())
|
|
60
|
+
top = kf.get("top_result", {}) or {}
|
|
61
|
+
if top:
|
|
62
|
+
tref = top.get("ref")
|
|
63
|
+
tmark = f"[{tref}] " if tref else ""
|
|
64
|
+
print(f" {tmark}{top.get('title', '')}")
|
|
65
|
+
snippet = top.get("snippet", "")
|
|
66
|
+
if snippet:
|
|
67
|
+
print(f" {snippet[:200]}")
|
|
68
|
+
findings = kf.get("findings", [])
|
|
69
|
+
if findings:
|
|
70
|
+
for f in findings:
|
|
71
|
+
title = f.get("title", "")
|
|
72
|
+
print(f" - {title}")
|
|
73
|
+
print(f" (本方面 {kf.get('result_count', 0)} 条结果)")
|
|
74
|
+
print()
|
|
75
|
+
|
|
76
|
+
# 知识缺口
|
|
77
|
+
gaps = report.get("gaps", [])
|
|
78
|
+
if gaps:
|
|
79
|
+
print("## 知识缺口")
|
|
80
|
+
for g in gaps:
|
|
81
|
+
print(f" - {g}")
|
|
82
|
+
print()
|
|
83
|
+
|
|
84
|
+
# 交叉引用
|
|
85
|
+
cross_refs = report.get("cross_references", [])
|
|
86
|
+
if cross_refs:
|
|
87
|
+
print("## 交叉验证")
|
|
88
|
+
for cr in cross_refs[:5]:
|
|
89
|
+
print(f" - 「{cr.get('ngram', '')}」被 {cr.get('source_count', 0)} 个来源佐证:{', '.join(cr.get('domains', [])[:5])}")
|
|
90
|
+
print()
|
|
91
|
+
|
|
92
|
+
# Verify 阶段:可信度评分 + 佐证强度(Selection×Absorption)
|
|
93
|
+
cv = report.get("cross_verification") or {}
|
|
94
|
+
if cv.get("credibility_available"):
|
|
95
|
+
print("## 证据核验(Verify)")
|
|
96
|
+
print(f" 佐证强度:{cv.get('corroboration_level', 'unknown')} | "
|
|
97
|
+
f"交叉分:{cv.get('cross_score', 0):.2f} | "
|
|
98
|
+
f"可吸收域名:{cv.get('content_domains', 0)}/{cv.get('unique_domains', 0)}")
|
|
99
|
+
for ts in cv.get("top_sources", [])[:3]:
|
|
100
|
+
print(f" - {ts.get('final', 0):.2f} {ts.get('source', '')} {ts.get('url', '')[:80]}")
|
|
101
|
+
for cf in cv.get("conflicts", [])[:3]:
|
|
102
|
+
print(f" ⚠ {cf.get('dimension', '')}:{cf.get('detail', '')}")
|
|
103
|
+
if cv.get("unverified_count"):
|
|
104
|
+
print(f" ⚠ {cv.get('unverified_count')} 个维度无结果可核实")
|
|
105
|
+
print()
|
|
106
|
+
|
|
107
|
+
# 事实保持一致:跨源事实冲突与印证
|
|
108
|
+
fa = report.get("fact_alignment")
|
|
109
|
+
if fa:
|
|
110
|
+
stats = fa.get("stats") or {}
|
|
111
|
+
conflicts = fa.get("fact_conflicts") or []
|
|
112
|
+
corroborated = fa.get("fact_corroborated") or []
|
|
113
|
+
print("## 事实对齐(Fact Alignment)")
|
|
114
|
+
print(f" 抽取 {stats.get('facts_extracted', 0)} 个事实 | "
|
|
115
|
+
f"冲突 {stats.get('conflicts', 0)} | "
|
|
116
|
+
f"印证 {stats.get('corroborated', 0)}")
|
|
117
|
+
for cf in conflicts[:5]:
|
|
118
|
+
vals = " vs ".join(f"{v['value']}({'/'.join(v['domains'][:2])})"
|
|
119
|
+
for v in cf.get("values", [])[:3])
|
|
120
|
+
print(f" ⚠ {cf.get('type', '')}: {vals}")
|
|
121
|
+
for co in corroborated[:5]:
|
|
122
|
+
print(f" ✓ {co.get('type', '')} {co.get('value', '')} "
|
|
123
|
+
f"({'/'.join(co.get('domains', [])[:3])})")
|
|
124
|
+
print()
|
|
125
|
+
|
|
126
|
+
# 固定工具预算提示
|
|
127
|
+
budget_info = report.get("budget")
|
|
128
|
+
if budget_info and budget_info.get("exhausted"):
|
|
129
|
+
print(f"## 预算提示")
|
|
130
|
+
print(f" 工具预算 {budget_info.get('limit')} 已用尽,本报告为最佳部分答案;未覆盖维度见知识缺口/盲区。")
|
|
131
|
+
print()
|
|
132
|
+
|
|
133
|
+
# 知识缺口
|
|
134
|
+
gaps = report.get("gaps") or []
|
|
135
|
+
if gaps:
|
|
136
|
+
print("## 知识缺口 / 盲区")
|
|
137
|
+
for g in gaps[:8]:
|
|
138
|
+
print(f" - {g}")
|
|
139
|
+
print()
|
|
140
|
+
|
|
141
|
+
qgr = report.get("quality_gate_results") or {}
|
|
142
|
+
if qgr:
|
|
143
|
+
print("## 取证门禁")
|
|
144
|
+
status = "通过" if qgr.get("passed") else "未通过"
|
|
145
|
+
print(f" {status} | 结论上限:{qgr.get('conclusion_cap', '')}")
|
|
146
|
+
for item in (qgr.get("failures") or []):
|
|
147
|
+
print(f" ✗ {item.get('id')}: {item.get('detail', '')}")
|
|
148
|
+
for item in (qgr.get("warnings") or []):
|
|
149
|
+
print(f" ⚠ {item.get('id')}: {item.get('detail', '')}")
|
|
150
|
+
print()
|
|
151
|
+
|
|
152
|
+
# topic profile 字符串清单:给 Agent 写判断稿,不是机器谓词
|
|
153
|
+
gates = report.get("quality_gates") or []
|
|
154
|
+
if gates:
|
|
155
|
+
print("## 判断稿自检(Agent)")
|
|
156
|
+
for g in gates:
|
|
157
|
+
print(f" - {g}")
|
|
158
|
+
print()
|
|
159
|
+
|
|
160
|
+
sections = report.get("report_sections") or []
|
|
161
|
+
if sections:
|
|
162
|
+
print("## 建议报告结构")
|
|
163
|
+
print(" → " + " / ".join(sections))
|
|
164
|
+
print()
|
|
165
|
+
|
|
166
|
+
grades = report.get("source_grades") or {}
|
|
167
|
+
if grades:
|
|
168
|
+
print("## 信源级别参考")
|
|
169
|
+
for level, items in grades.items():
|
|
170
|
+
if isinstance(items, list):
|
|
171
|
+
print(f" - {level}:{', '.join(str(x) for x in items[:6])}")
|
|
172
|
+
else:
|
|
173
|
+
print(f" - {level}:{items}")
|
|
174
|
+
print()
|
|
175
|
+
|
|
176
|
+
if report.get("disclaimer"):
|
|
177
|
+
print(f"⚠ {report['disclaimer']}")
|
|
178
|
+
print()
|
|
179
|
+
|
|
180
|
+
# 来源分布
|
|
181
|
+
source_dist = report.get("source_distribution", {})
|
|
182
|
+
if source_dist:
|
|
183
|
+
print("## 引擎分布")
|
|
184
|
+
for src, cnt in sorted(source_dist.items(), key=lambda x: x[1], reverse=True):
|
|
185
|
+
print(f" - {src}: {cnt}")
|
|
186
|
+
print()
|
|
187
|
+
|
|
188
|
+
engines = report.get("engines_used", [])
|
|
189
|
+
if engines:
|
|
190
|
+
print(f"使用引擎:{', '.join(engines)}")
|
|
191
|
+
print()
|
|
192
|
+
|
|
193
|
+
# 底部相关信源(传统搜索引擎形态;引用与 sources 统一)
|
|
194
|
+
if sources or citations:
|
|
195
|
+
print(f"── 相关信源({len(sources) or len(citations)})──")
|
|
196
|
+
rows = sources if sources else citations
|
|
197
|
+
for c in rows:
|
|
198
|
+
if not isinstance(c, dict):
|
|
199
|
+
continue
|
|
200
|
+
ref = c.get("ref") or (c.get("id") or "").strip("[]") or "?"
|
|
201
|
+
title = (c.get("title") or "")[:70]
|
|
202
|
+
eng = c.get("engine") or c.get("source") or ""
|
|
203
|
+
url = c.get("url") or ""
|
|
204
|
+
eng_s = f" · {eng}" if eng else ""
|
|
205
|
+
if title:
|
|
206
|
+
print(f" [{ref}] {title}{eng_s}")
|
|
207
|
+
if url:
|
|
208
|
+
print(f" {url}")
|
|
209
|
+
print()
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
research_strategy.py — 深度研究路由策略解析(从 research.py 拆分)
|
|
4
|
+
|
|
5
|
+
把「决策树路由」的推导从 collect_sources 的 _search_one 闭包里提取为
|
|
6
|
+
纯函数,减少闭包内部分支复杂度(code-review:special-case branching)。
|
|
7
|
+
|
|
8
|
+
策略语义:
|
|
9
|
+
- local_first:先试零成本本地聚合;结果不足阈值再升级通用/垂直源
|
|
10
|
+
- cost_aware(默认):mode=fast 自动走 local_first;其余按 mode
|
|
11
|
+
- full:直接全量,不走两段式
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from functools import lru_cache
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@lru_cache(maxsize=8)
|
|
20
|
+
def resolve_route_strategy(route_strategy: str | None, mode: str) -> str:
|
|
21
|
+
"""把显式策略 + mode 解析为实际生效策略(local_first / cost_aware / full)。
|
|
22
|
+
|
|
23
|
+
显式策略优先;未指定时按 mode 推导(fast → local_first)。
|
|
24
|
+
"""
|
|
25
|
+
if route_strategy in ("local_first", "full"):
|
|
26
|
+
return route_strategy
|
|
27
|
+
if route_strategy == "cost_aware":
|
|
28
|
+
return "cost_aware"
|
|
29
|
+
# 未指定 → 默认 cost_aware;fast 模式自动本地优先
|
|
30
|
+
if mode == "fast":
|
|
31
|
+
return "local_first"
|
|
32
|
+
return "cost_aware"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def should_use_local_first(strategy: str) -> bool:
|
|
36
|
+
"""该策略是否走「先本地、不足升级」的两段式。"""
|
|
37
|
+
return strategy == "local_first"
|