"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
docs: correct the MCP tool and skill counts, and hold them there with a test
Haozhe Wu75395771ed0e
diff --git a/README.md b/README.mdindex bb7ab3ff7..40593263a 100644--- a/README.md+++ b/README.md@@ -411,7 +411,7 @@ Beyond OHLCV, **18 read-only data tools** reach into fundamentals & flow — funDetailed inventories are folded below to keep the main README scannable. Open them when you want to inspect the available building blocks.<details>-<summary><b>Finance Skill Library</b> <sub>88 skills across 9 categories</sub></summary>+<summary><b>Finance Skill Library</b> <sub>89 skills across 9 categories</sub></summary>- 📊 88 specialized finance skills organized into 9 categories- 🌐 Complete coverage from traditional markets to crypto & DeFi@@ -1052,7 +1052,7 @@ Each fire runs the `prompt` through a fresh agent session (optional backtest par## 🔌 MCP Plugin-Vibe-Trading exposes 54 MCP tools for any MCP-compatible client. Runs as a stdio subprocess — no server setup needed. Core research tools work with zero API keys for HK/US/crypto; trading connector tools use the selected connector profile, and `run_swarm` needs an LLM key.+Vibe-Trading exposes 59 MCP tools for any MCP-compatible client. Runs as a stdio subprocess — no server setup needed. Core research tools work with zero API keys for HK/US/crypto; trading connector tools use the selected connector profile, and `run_swarm` needs an LLM key.**Environment variables:** the client spawns the server itself, so a shell `export` never reaches it — set them in the client's `env` block. Generated backtest code is sandboxed to the allowed run roots, so writing results into a workspace of your own needs `VIBE_TRADING_ALLOWED_RUN_ROOTS`:@@ -1121,7 +1121,7 @@ with `--host` / `--port`.</details>-**MCP tools exposed (55):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `iwencai_search`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`.+**MCP tools exposed (59):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `iwencai_search`, `get_institutional_holdings`, `etf_holdings`, `prediction_market`, `research_papers`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`.### SWARM external MCP toolsdiff --git a/README_ar.md b/README_ar.mdindex 43ab12c72..65b76e4f3 100644--- a/README_ar.md+++ b/README_ar.md@@ -382,7 +382,7 @@ vibe-trading run -p "Analyze my trading behavior, extract my shadow strategy, anالقوائم التفصيلية مطوية أدناه حتى يبقى README سهل القراءة. افتحها عندما تريد فحص اللبنات المتاحة.<details>-<summary><b>مكتبة المهارات المالية</b> <sub>88 مهارة عبر 9 فئات</sub></summary>+<summary><b>مكتبة المهارات المالية</b> <sub>89 مهارة عبر 9 فئات</sub></summary>- 📊 88 مهارة مالية متخصصة منظمة في 9 فئات- 🌐 تغطية كاملة من الأسواق التقليدية إلى الكريبتو وDeFi@@ -991,7 +991,7 @@ curl -X DELETE http://localhost:8899/scheduled-runs/<job_id>## 🔌 MCP Plugin-يعرض Vibe-Trading 54 أداة MCP لأي عميل متوافق مع MCP. يعمل كعملية stdio فرعية، دون إعداد خادم. أدوات البحث الأساسية تعمل دون أي مفاتيح API لأسواق HK/US/crypto؛ وأدوات connector للتداول تستخدم profile الموصل المختار، ويحتاج `run_swarm` وحده إلى مفتاح LLM.+يعرض Vibe-Trading 59 أداة MCP لأي عميل متوافق مع MCP. يعمل كعملية stdio فرعية، دون إعداد خادم. أدوات البحث الأساسية تعمل دون أي مفاتيح API لأسواق HK/US/crypto؛ وأدوات connector للتداول تستخدم profile الموصل المختار، ويحتاج `run_swarm` وحده إلى مفتاح LLM.**متغيرات البيئة:** العميل هو من يشغّل الخادم بنفسه، لذا لا يصل إليه `export` من الـ shell أبداً —— اضبطها في كتلة `env` الخاصة بالعميل. كود الاختبار الخلفي المولَّد محصور ضمن جذور التشغيل المسموح بها، لذا تحتاج إلى `VIBE_TRADING_ALLOWED_RUN_ROOTS` لكتابة النتائج في دليل عمل خاص بك:@@ -1047,7 +1047,7 @@ vibe-trading-mcp --transport sse # legacy SSE (deprecated)</details>-**أدوات MCP المعروضة (54):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `analyze_options`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `iwencai_search`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`.+**أدوات MCP المعروضة (59):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `iwencai_search`, `get_institutional_holdings`, `etf_holdings`, `prediction_market`, `research_papers`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`.<details><summary><b>التثبيت من ClawHub (أمر واحد)</b></summary>diff --git a/README_ja.md b/README_ja.mdindex 35aeab811..a9255ec43 100644--- a/README_ja.md+++ b/README_ja.md@@ -382,7 +382,7 @@ OHLCV にとどまらず、**18 の読み取り専用データツール**がフメイン README を読みやすく保つため、詳細な一覧は以下に折りたたんでいます。利用できる構成要素を確認したいときに開いてください。<details>-<summary><b>Finance Skill Library</b> <sub>9カテゴリにわたる88 skills</sub></summary>+<summary><b>Finance Skill Library</b> <sub>9カテゴリにわたる89 skills</sub></summary>- 📊 88 の金融特化 skills を 9 カテゴリに整理- 🌐 伝統的市場から crypto & DeFi まで完全カバー@@ -988,7 +988,7 @@ curl -X DELETE http://localhost:8899/scheduled-runs/<job_id>## 🔌 MCP Plugin-Vibe-Trading は MCP-compatible client 向けに 54 MCP tools を公開します。stdio subprocess として動作し、server setup は不要です。Core research tools は HK/US/crypto で API key なしに動作し、trading connector tools は選択中の connector profile を使います。LLM key が必要なのは `run_swarm` のみです。+Vibe-Trading は MCP-compatible client 向けに 59 MCP tools を公開します。stdio subprocess として動作し、server setup は不要です。Core research tools は HK/US/crypto で API key なしに動作し、trading connector tools は選択中の connector profile を使います。LLM key が必要なのは `run_swarm` のみです。**環境変数:** server は client 自身が spawn するため、shell の `export` は届きません —— client の `env` block に設定してください。生成された backtest code は allowed run roots 内に制限されるので、結果を自分の作業 directory に書き出すには `VIBE_TRADING_ALLOWED_RUN_ROOTS` が必要です:@@ -1044,7 +1044,7 @@ vibe-trading-mcp --transport sse # legacy SSE (deprecated)</details>-**公開される MCP tools(54):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `analyze_options`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `iwencai_search`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`.+**公開される MCP tools(59):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `iwencai_search`, `get_institutional_holdings`, `etf_holdings`, `prediction_market`, `research_papers`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`.<details><summary><b>ClawHub からインストール(1 コマンド)</b></summary>diff --git a/README_ko.md b/README_ko.mdindex 221f4e4bb..e6584f1d6 100644--- a/README_ko.md+++ b/README_ko.md@@ -382,7 +382,7 @@ OHLCV를 넘어 **18개 읽기 전용 데이터 도구**가 펀더멘털과 자메인 README를 읽기 쉽게 유지하기 위해 상세 목록은 아래에 접어 두었습니다. 사용 가능한 구성 요소를 확인하고 싶을 때 열어보세요.<details>-<summary><b>금융 스킬 라이브러리</b> <sub>9개 카테고리 88개 스킬</sub></summary>+<summary><b>금융 스킬 라이브러리</b> <sub>9개 카테고리 89개 스킬</sub></summary>- 📊 9개 카테고리로 구성된 88개 전문 금융 스킬- 🌐 전통 시장부터 크립토 & DeFi까지 완전한 커버리지@@ -991,7 +991,7 @@ curl -X DELETE http://localhost:8899/scheduled-runs/<job_id>## 🔌 MCP Plugin-Vibe-Trading은 모든 MCP-compatible client를 위해 54개 MCP tools를 제공합니다. stdio subprocess로 실행되므로 server setup이 필요 없습니다. 핵심 research tools는 HK/US/crypto에서 API key 없이 작동하고, trading connector tools는 선택된 connector profile을 사용하며, `run_swarm`만 LLM key가 필요합니다.+Vibe-Trading은 모든 MCP-compatible client를 위해 59개 MCP tools를 제공합니다. stdio subprocess로 실행되므로 server setup이 필요 없습니다. 핵심 research tools는 HK/US/crypto에서 API key 없이 작동하고, trading connector tools는 선택된 connector profile을 사용하며, `run_swarm`만 LLM key가 필요합니다.**환경 변수:** server는 client가 직접 spawn하므로 shell의 `export`는 전달되지 않습니다 —— client의 `env` block에 설정하세요. 생성된 backtest code는 allowed run roots 안으로 제한되므로, 결과를 자신의 작업 directory에 쓰려면 `VIBE_TRADING_ALLOWED_RUN_ROOTS`가 필요합니다:@@ -1047,7 +1047,7 @@ vibe-trading-mcp --transport sse # legacy SSE (deprecated)</details>-**노출되는 MCP tools(54):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `analyze_options`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `iwencai_search`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`.+**노출되는 MCP tools(59):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `iwencai_search`, `get_institutional_holdings`, `etf_holdings`, `prediction_market`, `research_papers`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`.<details><summary><b>ClawHub에서 설치(한 번의 명령)</b></summary>diff --git a/README_zh.md b/README_zh.mdindex a6db813aa..88e637f54 100644--- a/README_zh.md+++ b/README_zh.md@@ -411,7 +411,7 @@ LONGBRIDGE_ACCESS_TOKEN=...为保持主 README 易读,详细清单折叠在下方。需要检查可用构件时可展开查看。<details>-<summary><b>Finance Skill Library</b> <sub>9 个类别中的 88 个 skills</sub></summary>+<summary><b>Finance Skill Library</b> <sub>9 个类别中的 89 个 skills</sub></summary>- 📊 88 个专业金融 skills,分布在 9 个类别中- 🌐 覆盖传统市场、加密与 DeFi@@ -1015,7 +1015,7 @@ curl -X DELETE http://localhost:8899/scheduled-runs/<job_id>## 🔌 MCP Plugin-Vibe-Trading 为任何 MCP-compatible client 暴露 54 个 MCP tools。它作为 stdio subprocess 运行,无需 server setup。核心 research tools 对港股/美股/加密零 API key 可用;trading connector tools 使用当前选择的 connector profile;只有 `run_swarm` 需要 LLM key。+Vibe-Trading 为任何 MCP-compatible client 暴露 59 个 MCP tools。它作为 stdio subprocess 运行,无需 server setup。核心 research tools 对港股/美股/加密零 API key 可用;trading connector tools 使用当前选择的 connector profile;只有 `run_swarm` 需要 LLM key。**环境变量:** server 由 client 自己 spawn,因此在 shell 里 `export` 永远传不进去 —— 请写在 client 的 `env` 块里。生成的回测代码被限制在 allowed run roots 内,所以要把结果写进你自己的工作目录,需要 `VIBE_TRADING_ALLOWED_RUN_ROOTS`:@@ -1071,7 +1071,7 @@ vibe-trading-mcp --transport sse # legacy SSE (deprecated)</details>-**暴露的 MCP tools(54):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `analyze_options`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `iwencai_search`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`.+**暴露的 MCP tools(59):** `list_skills`, `load_skill`, `start_research_goal`, `get_research_goal`, `add_goal_evidence`, `update_research_goal_status`, `backtest`, `factor_analysis`, `analyze_options`, `analyze_options_payoff`, `pattern_recognition`, `read_url`, `read_document`, `web_search`, `write_file`, `read_file`, `list_swarm_presets`, `run_swarm`, `get_market_data`, `get_fund_flow`, `get_dragon_tiger`, `get_northbound_flow`, `get_margin_trading`, `get_block_trades`, `get_shareholder_count`, `get_lockup_expiry`, `get_sector_info`, `get_research_reports`, `get_stock_news`, `get_sec_filings`, `get_financial_statements`, `get_options_chain`, `get_stock_profile`, `screen_market`, `search_symbol`, `get_macro_series`, `iwencai_search`, `get_institutional_holdings`, `etf_holdings`, `prediction_market`, `research_papers`, `get_swarm_status`, `get_run_result`, `list_runs`, `reap_stale_runs`, `retry_run`, `analyze_trade_journal`, `extract_shadow_strategy`, `run_shadow_backtest`, `render_shadow_report`, `scan_shadow_signals`, `trading_connections`, `trading_select_connection`, `trading_check`, `trading_account`, `trading_positions`, `trading_orders`, `trading_quote`, `trading_history`.<details><summary><b>从 ClawHub 安装(一条命令)</b></summary>diff --git a/agent/tests/test_readme_counts.py b/agent/tests/test_readme_counts.pynew file mode 100644index 000000000..36565971e--- /dev/null+++ b/agent/tests/test_readme_counts.py@@ -0,0 +1,245 @@+"""The five READMEs must agree with the code about how much of everything ships.++Every number these tests check is one a reader uses to decide whether the+project does what they need — how many MCP tools they get, how many skills,+how many backtest engines. They drift silently: a feature lands, the English+README is updated by hand, and the four translations keep yesterday's count+until somebody happens to look. Both counts these tests were written for had+already drifted this way (``analyze_options_payoff`` was missing from four+locale tool lists, and the ``investor-lenses`` skill from all five badges).++Locale independence is the whole difficulty. The numbers sit inside translated+prose, so nothing can be matched on wording. Instead each check anchors on+something that survives translation:++* the enumerated MCP tool list — the line carrying the most ``\\`name\\``+ literals, whose contents are code identifiers in every locale;+* the repository-tree line, anchored on ``mcp_server.py``;+* the MCP prose paragraph, anchored on ``stdio`` — dated news bullets are+ excluded, because an old entry mentions stdio too;+* the feature badges, anchored on ``<summary>…<sub>N …</sub></summary>``. The+ enclosing ``<summary>`` matters: a loose ``<sub>`` ("Plus 20+ specialist+ presets") sits among them, and it wraps onto its own line in English but not+ in the other four, so counting bare ``<sub>`` elements puts the locales out+ of step with one another.++A badge is asserted to *contain* its expected number rather than to start with+it, because the word order differs by language — "89 skills across 9+categories" against "9 个类别中的 89 个 skills". That still fails the moment the+code count moves, which is what this file is for.+"""++from __future__ import annotations++import asyncio+import importlib+import re+import sys+from pathlib import Path++import pytest++REPO_ROOT = Path(__file__).resolve().parents[2]+AGENT_DIR = Path(__file__).resolve().parents[1]++READMES = (+ "README.md",+ "README_zh.md",+ "README_ja.md",+ "README_ko.md",+ "README_ar.md",+)++# Feature badges in the order they appear in every README. Each entry is the+# badge's position among numeric <sub> badges and a callable returning the+# count the code actually ships.+BADGE_ORDER = ("skills", "brokers", "presets", "alphas", "engines")++# Brokers are a curated product claim (which venues we support), not something+# countable from a single directory — connectors, profiles and the read-only+# caps do not map one-to-one. It is pinned here so a reader-facing number still+# has one owner, and updating it is a deliberate edit.+EXPECTED_BROKERS = 12+++def _read(name: str) -> str:+ """Return a README's text.++ Args:+ name: File name relative to the repository root.++ Returns:+ The file contents.+ """+ return (REPO_ROOT / name).read_text(encoding="utf-8")+++def _mcp_tool_names() -> list[str]:+ """Return the MCP tool names in registration order.++ Returns:+ Tool names exactly as the MCP server exposes them.+ """+ if str(AGENT_DIR) not in sys.path:+ sys.path.insert(0, str(AGENT_DIR))+ mod = sys.modules.get("mcp_server") or importlib.import_module("mcp_server")+ return [tool.name for tool in asyncio.run(mod.mcp.list_tools())]+++def _bundled_skill_count() -> int:+ """Count skills that ship inside the package.++ User-created skills live outside the checkout and must not be counted, so+ the loader is pointed at a directory that cannot exist.++ Returns:+ Number of bundled skills.+ """+ if str(AGENT_DIR) not in sys.path:+ sys.path.insert(0, str(AGENT_DIR))+ from src.agent.skills import SkillsLoader++ loader = SkillsLoader(user_skills_dir=AGENT_DIR / "__no_user_skills__")+ return len(loader.skills)+++def _engine_count() -> int:+ """Count market backtest engines.++ ``options_portfolio`` is counted separately by the README ("9 engines ++ options portfolio"), and the shared bases are not engines.++ Returns:+ Number of market engines.+ """+ excluded = {"__init__", "base", "futures_base", "_market_hooks", "options_portfolio"}+ return len(+ [p for p in (AGENT_DIR / "backtest" / "engines").glob("*.py") if p.stem not in excluded]+ )+++def _counts() -> dict[str, int]:+ """Return every code-derived count the READMEs state.++ Returns:+ Mapping of badge key to the count the code ships.+ """+ return {+ "skills": _bundled_skill_count(),+ "brokers": EXPECTED_BROKERS,+ "presets": len(list((AGENT_DIR / "src" / "swarm" / "presets").glob("*.yaml"))),+ "alphas": len([p for p in (AGENT_DIR / "src" / "factors" / "zoo").rglob("*.py")+ if p.stem != "__init__"]),+ "engines": _engine_count(),+ }+++def _tool_list_line(text: str) -> str:+ """Return the line enumerating every MCP tool.++ Args:+ text: Full README text.++ Returns:+ The line carrying the most backticked identifiers.+ """+ return max(text.splitlines(), key=lambda line: len(re.findall(r"`[a-z_]+`", line)))+++SUMMARY_BADGE = re.compile(r"<summary>[^\n]*<sub>([^<]*\d[^<]*)</sub>[^\n]*</summary>")++NEWS_BULLET = re.compile(r"- \*\*\d{4}-")+++def _badges(text: str) -> list[str]:+ """Return the feature badges in document order.++ Args:+ text: Full README text.++ Returns:+ The numeric ``<sub>`` badge texts that sit inside a ``<summary>``.+ """+ return SUMMARY_BADGE.findall(text)+++def _numbers(line: str) -> set[str]:+ """Return every integer appearing in a line.++ Args:+ line: Text to scan.++ Returns:+ The integers found, as strings.+ """+ return set(re.findall(r"\d+", line))++[email protected]("name", READMES)+def test_enumerated_mcp_tool_list_matches_the_server(name: str) -> None:+ """The spelled-out tool list must be the server's list, in its order."""+ listed = re.findall(r"`([a-z_]+)`", _tool_list_line(_read(name)))+ runtime = _mcp_tool_names()++ assert set(listed) == set(runtime), (+ f"{name}: missing {sorted(set(runtime) - set(listed))}, "+ f"stale {sorted(set(listed) - set(runtime))}"+ )+ assert len(listed) == len(runtime), f"{name}: a tool name is listed twice"++[email protected]("name", READMES)+def test_enumerated_mcp_list_header_states_the_real_count(name: str) -> None:+ """The "(N)" heading on the tool list must be the real tool count."""+ line = _tool_list_line(_read(name))+ header = re.search(r"[((](\d+)[))]", line[:60])++ assert header is not None, f"{name}: tool list has no (N) header"+ assert int(header.group(1)) == len(_mcp_tool_names())++[email protected]("name", READMES)+def test_mcp_prose_states_the_real_count(name: str) -> None:+ """The MCP section paragraph must state the real tool count."""+ prose = [+ line+ for line in _read(name).splitlines()+ if "stdio" in line and re.search(r"\d\d", line) and not NEWS_BULLET.match(line)+ ]++ assert len(prose) == 1, f"{name}: expected one MCP prose line, found {len(prose)}"+ assert str(len(_mcp_tool_names())) in _numbers(prose[0])++[email protected]("name", READMES)+def test_repo_tree_states_the_real_mcp_count(name: str) -> None:+ """The repository-tree comment on mcp_server.py must state the real count."""+ tree = [line for line in _read(name).splitlines() if "mcp_server.py" in line and "#" in line]++ assert len(tree) == 1, f"{name}: expected one mcp_server.py tree line, found {len(tree)}"+ assert str(len(_mcp_tool_names())) in _numbers(tree[0])++[email protected]("name", READMES)+def test_feature_badges_state_the_real_counts(name: str) -> None:+ """Each <sub> badge must carry the count the code ships."""+ badges = _badges(_read(name))+ counts = _counts()++ assert len(badges) == len(BADGE_ORDER), (+ f"{name}: expected {len(BADGE_ORDER)} numeric badges, found {len(badges)}: {badges}"+ )+ for badge, key in zip(badges, BADGE_ORDER):+ assert str(counts[key]) in _numbers(badge), (+ f"{name}: {key} badge says {badge!r}, code ships {counts[key]}"+ )+++def test_all_five_readmes_agree_with_each_other() -> None:+ """No locale may drift from the others, whatever the code count is."""+ per_file = {name: [_numbers(b) for b in _badges(_read(name))] for name in READMES}+ counts = _counts()++ for index, key in enumerate(BADGE_ORDER):+ stale = [name for name, badges in per_file.items() if str(counts[key]) not in badges[index]]+ assert not stale, f"{key}: {stale} disagree with the other locales"