{"id":"0b3833ae-6248-4880-89cc-04ea988ae4f8","entityType":"agent","slug":"clawhub-medstatstar-ct-samplesize","name":"Clinical Trial Sample Size & Power / 临床试验样本量与检验效能专家","canonicalUrl":"https://www.xpersona.co/agent/clawhub-medstatstar-ct-samplesize","canonicalPath":"/agent/clawhub-medstatstar-ct-samplesize","generatedAt":"2026-10-10T06:43:02.813Z","source":"CLAWHUB","claimStatus":"UNCLAIMED","verificationTier":"NONE","summary":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-09T18:17:45.160Z","emptyReason":null},"description":"Sample size and power calculation tool for clinical trial practitioners. No local R install needed — a cloud R compute service covers all 49 test types and returns publication-grade SVG figures. Natural-language driven; full reproducible R code is returned by default; default output in Chinese or English per OS language setting (prompt can force-switch). / 为临床试验从业者提供的样本量与检验效能计算工具。本地无需安装 R，直接提供云端 R 计算服务（覆盖 49 种检验，并提供 SVG 出版级别图形）。自然语言驱动，默认回传完整 R 代码；默认按操作系统语言设定输出中文或英文（提示词可强制切换）。","descriptionLabel":"Source description","evidenceSummary":"Capability contract not published. No trust telemetry is available yet. 2.1K downloads reported by the source. Last updated 10/9/2026.","installCommand":"clawhub skill install s176fv8983h1rte6dmxwp9wt4n89j8p5:ct-samplesize","sourceUrl":"https://clawhub.ai/medstatstar/ct-samplesize","homepage":"https://clawhub.ai/medstatstar/skills/ct-samplesize","primaryLinks":[{"label":"View on ClawHub","url":"https://clawhub.ai/medstatstar/ct-samplesize","kind":"source"},{"label":"Homepage","url":"https://clawhub.ai/medstatstar/skills/ct-samplesize","kind":"homepage"}],"safetyScore":84,"overallRank":62,"popularityScore":67,"trustScore":null,"claimedByName":null,"isOwner":false,"seoDescription":"Clinical Trial Sample Size & Power / 临床试验样本量与检验效能专家 technical dossier on Xpersona with agent coverage, OPENCLEW support, and live trust metadata."},"coverage":{"evidence":{"source":"public-profile","verified":false,"confidence":"medium","updatedAt":"2026-10-09T18:17:45.160Z","emptyReason":null},"protocols":[{"protocol":"OPENCLEW","label":"OpenClaw","status":"self-declared","notes":"Declared in the public agent profile."}],"capabilities":[],"verifiedCount":0,"selfDeclaredCount":1,"capabilityMatrix":{"rows":[{"key":"OPENCLEW","type":"protocol","support":"unknown","confidenceSource":"profile","notes":"Listed on profile"}],"flattenedTokens":"protocol:OPENCLEW|unknown|profile"}},"adoption":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-09T18:17:45.160Z","emptyReason":null},"stars":null,"forks":null,"downloads":2146,"packageName":null,"latestVersion":"5.8.0","tractionLabel":"2.1K downloads"},"release":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-09T18:17:45.132Z","emptyReason":null},"lastUpdatedAt":"2026-10-09T18:17:45.160Z","lastCrawledAt":"2026-10-09T18:17:45.132Z","lastIndexedAt":null,"nextCrawlAt":"2026-10-10T18:17:45.132Z","lastVerifiedAt":null,"highlights":[{"version":"5.8.0","createdAt":"2026-10-09T12:10:53.622Z","changelog":"No changes detected in this version. - Version bumped to 5.8.0 with no file/content updates. - Functionality, features, and documentation remain unchanged.","fileCount":68,"zipByteSize":477531},{"version":"5.6.1","createdAt":"2026-10-09T12:05:26.559Z","changelog":"## ct-samplesize v5.8.0 Changelog - Added published app deployment metadata and details, including public share link, appId, and publish/re-publish rules in documentation. - Enhanced permissions/payload: outbound requests now include the `skill_version` for improved cloud usage attribution. - Deterministic natural language pre-routing is now *deterministic-first*: raw NL text is never sent to coze; when parameter rules fail, a conversation-mode fallback handles missing data locally (≤2 rounds, then defaults) before any remote compute. - Added support for LongCat-2.0 as the default LLM fallback model for NL handling (locally, not cloud); added key loader/override mechanism. - Documentation expanded for workbench deployment, curve/figure handling, and added or updated backend optimization, batch call, and drug name resolution references. - New scripts and configuration for backend optimization, batch API calls, keyword processing, and metadata mapping. Removed outdated `skill-card.md`.","fileCount":68,"zipByteSize":477468},{"version":"5.6.0","createdAt":"2026-08-30T10:29:18.388Z","changelog":"v5.6.0: make adapters/coze the single source of truth (remove legacy r-assets, eliminate 934-line drift); directory cleanup; trim SKILL.md 256->196 lines; rebuild release packages.","fileCount":51,"zipByteSize":322753},{"version":"5.3.14","createdAt":"2026-08-29T02:26:52.271Z","changelog":"coze return payload restructure: full JSON externalized as single S3 file (aligned with ct-base §20.8); inline trimmed copy (<4000); fixed 4116>4000 regression","fileCount":63,"zipByteSize":263998},{"version":"5.3.12","createdAt":"2026-08-28T15:09:38.017Z","changelog":"Add coze concurrency rate-limit (>=1s between /run calls, ct-base 20.10); refactor envelope drift detection into single _assess_contract entry (ct-base 20.9); SKILL.md English body <=200 lines; align cross-turn continuity menu with ct-base 1.1/5.1.","fileCount":63,"zipByteSize":262153},{"version":"5.1.0","createdAt":"2026-08-23T01:10:34.121Z","changelog":"Add bug report feature (ct-base 20.3); whitelist bugreport endpoint; README disclosure. Coze cloud code excluded.","fileCount":38,"zipByteSize":185244},{"version":"5.0.1","createdAt":"2026-08-23T01:08:12.128Z","changelog":"v5.1.0 introduces stricter remote compute handling and network policy updates. - Network access is now required for all sample size/power calculations (no local compute fallback). - All compute requests include a secure hostname hash (\"query_origin\") and locale metadata for server attribution and language handling. - Updated data boundary note: only trial-design parameters, query_origin, and locale leave the machine—never patient data. - Outbound authorization gates clarified—public endpoint never prompts; custom endpoints require explicit confirmation. - Documentation and metadata updated for new network and privacy requirements.","fileCount":38,"zipByteSize":185331},{"version":"5.0.0","createdAt":"2026-08-21T00:44:27.952Z","changelog":"Upgrade from local-compute to cloud-server version: all 49 tests computed by remote coze R engine (no local R); local fallback removed; explicit locale param (zh/en); ct-base §16 pre-publish compliance.","fileCount":37,"zipByteSize":167003}]},"execution":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No published capability contract is available yet."},"installCommand":"clawhub skill install s176fv8983h1rte6dmxwp9wt4n89j8p5:ct-samplesize","setupComplexity":"low","setupSteps":["Install using `clawhub skill install s176fv8983h1rte6dmxwp9wt4n89j8p5:ct-samplesize` in an isolated environment before connecting it to live workloads.","No published capability contract is available yet, so validate auth and request/response behavior manually.","Review the upstream CLAWHUB listing at https://clawhub.ai/medstatstar/ct-samplesize before using production credentials."],"contract":{"contractStatus":"missing","authModes":[],"requires":[],"forbidden":[],"supportsMcp":false,"supportsA2a":false,"supportsStreaming":false,"inputSchemaRef":null,"outputSchemaRef":null,"dataRegion":null,"contractUpdatedAt":null,"sourceUpdatedAt":null,"freshnessSeconds":null},"invocationGuide":{"preferredApi":{"snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-medstatstar-ct-samplesize/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-medstatstar-ct-samplesize/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-medstatstar-ct-samplesize/trust"},"curlExamples":["curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-medstatstar-ct-samplesize/snapshot\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-medstatstar-ct-samplesize/contract\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-medstatstar-ct-samplesize/trust\""],"jsonRequestTemplate":{"query":"summarize this repo","constraints":{"maxLatencyMs":2000,"protocolPreference":["OPENCLEW"]}},"jsonResponseTemplate":{"ok":true,"result":{"summary":"...","confidence":0.9},"meta":{"source":"CLAWHUB","generatedAt":"2026-10-10T06:43:02.809Z"}},"retryPolicy":{"maxAttempts":3,"backoffMs":[500,1500,3500],"retryableConditions":["HTTP_429","HTTP_503","NETWORK_TIMEOUT"]}},"endpoints":{"dossierUrl":"https://www.xpersona.co/api/v1/agents/clawhub-medstatstar-ct-samplesize/dossier","snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-medstatstar-ct-samplesize/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-medstatstar-ct-samplesize/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-medstatstar-ct-samplesize/trust"}},"reliability":{"evidence":{"source":"runtime-metrics","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No trust, reliability, or runtime telemetry is available."},"trust":{"status":"unavailable","handshakeStatus":"UNKNOWN","verificationFreshnessHours":null,"reputationScore":null,"p95LatencyMs":null,"successRate30d":null,"fallbackRate":null,"attempts30d":null,"trustUpdatedAt":null,"trustConfidence":"unknown","sourceUpdatedAt":null,"freshnessSeconds":null},"decisionGuardrails":{"doNotUseIf":["Contract metadata is missing or unavailable for deterministic execution."],"safeUseWhen":[],"riskFlags":["missing_or_unavailable_contract","trust_data_unavailable","schema_references_missing"],"operationalConfidence":"low"},"executionMetrics":{"observedLatencyMsP50":null,"observedLatencyMsP95":null,"estimatedCostUsd":null,"uptime30d":null,"rateLimitRpm":null,"rateLimitBurst":null,"lastVerifiedAt":null,"verificationSource":null},"runtimeMetrics":{"successRate":null,"avgLatencyMs":null,"avgCostUsd":null,"hallucinationRate":null,"retryRate":null,"disputeRate":null,"p50Latency":null,"p95Latency":null,"lastUpdated":null}},"benchmarks":{"evidence":{"source":"no-benchmark-data","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No benchmark suites or observed failure patterns are available."},"suites":[],"failurePatterns":[]},"artifacts":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-09T18:17:45.160Z","emptyReason":null},"readme":"Skill: Clinical Trial Sample Size & Power / 临床试验样本量与检验效能专家\n\nOwner: medstatstar\n\nSummary: Sample size and power calculation tool for clinical trial practitioners. No local R install needed — a cloud R compute service covers all 49 test types and returns publication-grade SVG figures. Natural-language driven; full reproducible R code is returned by default; default output in Chinese or English per OS language setting (prompt can force-switch). / 为临床试验从业者提供的样本量与检验效能计算工具。本地无需安装 R，直接提供云端 R 计算服务（覆盖 49 种检验，并提供 SVG 出版级别图形）。自然语言驱动，默认回传完整 R 代码；默认按操作系统语言设定输出中文或英文（提示词可强制切换）。\n\nTags: latest:5.8.0\n\nVersion history:\n\nv5.8.0 | 2026-10-09T12:10:53.622Z | auto\n\nNo changes detected in this version.\n\n- Version bumped to 5.8.0 with no file/content updates.\n- Functionality, features, and documentation remain unchanged.\n\nv5.6.1 | 2026-10-09T12:05:26.559Z | auto\n\n## ct-samplesize v5.8.0 Changelog\n\n- Added published app deployment metadata and details, including public share link, appId, and publish/re-publish rules in documentation.\n- Enhanced permissions/payload: outbound requests now include the `skill_version` for improved cloud usage attribution.\n- Deterministic natural language pre-routing is now *deterministic-first*: raw NL text is never sent to coze; when parameter rules fail, a conversation-mode fallback handles missing data locally (≤2 rounds, then defaults) before any remote compute.\n- Added support for LongCat-2.0 as the default LLM fallback model for NL handling (locally, not cloud); added key loader/override mechanism.\n- Documentation expanded for workbench deployment, curve/figure handling, and added or updated backend optimization, batch call, and drug name resolution references.\n- New scripts and configuration for backend optimization, batch API calls, keyword processing, and metadata mapping. Removed outdated `skill-card.md`.\n\nv5.6.0 | 2026-08-30T10:29:18.388Z | user\n\nv5.6.0: make adapters/coze the single source of truth (remove legacy r-assets, eliminate 934-line drift); directory cleanup; trim SKILL.md 256->196 lines; rebuild release packages.\n\nv5.3.14 | 2026-08-29T02:26:52.271Z | user\n\ncoze return payload restructure: full JSON externalized as single S3 file (aligned with ct-base §20.8); inline trimmed copy (<4000); fixed 4116>4000 regression\n\nv5.3.12 | 2026-08-28T15:09:38.017Z | user\n\nAdd coze concurrency rate-limit (>=1s between /run calls, ct-base 20.10); refactor envelope drift detection into single _assess_contract entry (ct-base 20.9); SKILL.md English body <=200 lines; align cross-turn continuity menu with ct-base 1.1/5.1.\n\nv5.1.0 | 2026-08-23T01:10:34.121Z | user\n\nAdd bug report feature (ct-base 20.3); whitelist bugreport endpoint; README disclosure. Coze cloud code excluded.\n\nv5.0.1 | 2026-08-23T01:08:12.128Z | auto\n\nv5.1.0 introduces stricter remote compute handling and network policy updates.\n\n- Network access is now required for all sample size/power calculations (no local compute fallback).\n- All compute requests include a secure hostname hash (\"query_origin\") and locale metadata for server attribution and language handling.\n- Updated data boundary note: only trial-design parameters, query_origin, and locale leave the machine—never patient data.\n- Outbound authorization gates clarified—public endpoint never prompts; custom endpoints require explicit confirmation.\n- Documentation and metadata updated for new network and privacy requirements.\n\nv5.0.0 | 2026-08-21T00:44:27.952Z | user\n\nUpgrade from local-compute to cloud-server version: all 49 tests computed by remote coze R engine (no local R); local fallback removed; explicit locale param (zh/en); ct-base §16 pre-publish compliance.\n\nv3.8.1 | 2026-08-02T11:52:44.849Z | user\n\nQA 红队 10 轮 × 10 案例真实跑 CLI（共 100 案例）：收紧 alpha 范围校验（拒绝 alpha>0.5）；同步 7 个缺失 GSD i18n 键到 R 运行时字典（I18N_R 237→244）消除运行时打印原始 key；为 --hazard_ratio 增加 --hr 别名修复 argparse 歧义报错；清理英文 README 中英混排小标题（遵循 ct-base 双语分两份 README 规范）。\n\nv3.8.0 | 2026-08-02T04:57:42.535Z | user\n\n优化用户菜单(UI)与README，对碳基生物用户（人类）更友好；文档英文-only（ct-base §13.2）\n\nv3.4.5 | 2026-07-20T13:34:34.478Z | user\n\nfix: use _r_cat helper to bypass Anaconda Python f-string bug\n\nv3.4.4 | 2026-07-19T12:14:49.760Z | user\n\nfeat(i18n): bilingual prompt infrastructure + inline R for publish safety\n\nv3.4.3 | 2026-07-18T02:54:04.958Z | user\n\nv3.4.3 remove R deny-list literals: dropped redundant dangerous-token deny-list from samplesize_power.py; strict allowlist (_validate_token/_safe_r_path_literal) is the real RCE defense, so literal system(/eval(/source(/download.file(/shell( are no longer in source, clearing static-analysis suspicious.dynamic_code_execution. Injection still blocked; SAFE PREVIEW default unchanged.\n\nv3.4.2 | 2026-07-18T02:43:32.781Z | user\n\nv3.4.2 doc consistency: unify default-execution docs (SAFE PREVIEW by default, --yes to execute) across cli_examples.md/examples.md/r_usage.md/AGENTS.md, resolving clawscan SDI-4; retains v3.4.1 R-injection allowlist hardening (unescaped --out fix).\n\nv3.3.8 | 2026-07-17T08:59:16.568Z | user\n\nv3.3.8 - Fix ClawHub skillSpector CRITICAL (9 findings, DO_NOT_INSTALL): moved permissions block from metadata:{} to top-level frontmatter so declared network/filesystem scope is visible; clarified filesystem writes to system temp (R script) and working dir (curve PNG). Reproducible code on request; English default with auto-Chinese on Chinese-OS.\n\nv3.3.7 | 2026-07-17T08:44:49.748Z | user\n\nv3.3.7 - Function-based architecture, security hardening, refined bilingual/R-code policy. All 37 test types now use pre-written R functions with closed-form fallbacks. Security: Rscript binary validation, temp-file containment, dangerous-token gate, no-shell subprocess. R code hidden by default; --show-code to display, --dry-run to preview. Language: English by default, auto-Chinese on Chinese-OS; dual EN/ZH for common modules.\n\nv3.3.1 | 2026-07-14T08:03:42.764Z | user\n\nClawHub 审计整改: R 模板诚信措辞(BuyseTest/Dunnett 夸大修正)、包安装默认仅打印命令(--run-install 显式执行)、SKILL.md 安全模型披露与双语放宽\n\nv3.2.1 | 2026-07-13T13:48:01.062Z | user\n\nv3.3.1：R 模板按类别拆分至 r_templates/ 子包；默认执行模式并始终附可复现 R 代码；logo SVG/PNG 调整（Clinical/Trial 下移、α 线左移进框）\n\nv3.2.0 | 2026-07-12T14:00:23.938Z | auto\n\n**ct-samplesize v3.2.0 changelog**\n\n- Local R code execution is now handled via subprocess (Rscript), increasing safety and clarity.\n- R code is only displayed on-demand, never by default; use trigger phrases like \"带代码\" or \"with R code\" to request.\n- Improved and clarified permissions and warnings: all R scripts are generated in a temp location within the skill directory; users are strongly advised to review code before running.\n- Expanded and improved bilingual (EN/CN) triggers for more flexible user commands.\n- Documentation updated and streamlined for clarity, including all usage and privilege disclosures.\n- Obsolete `skill-card.md` removed.\n\nv3.1.0 | 2026-07-12T13:27:42.416Z | auto\n\n**Changelog for ct-samplesize 3.1.0**\n\n- R code output is now hidden by default and provided only upon explicit user request.\n- Enhanced security and user control: all R code execution requires explicit user confirmation (`-y/--yes` flag).\n- Updated output standard: every analysis includes a complete results report (parameters, results, interpretation, assumptions). \n- Added clear user safety warnings regarding code execution and regulatory usage.\n- Tightened Python dependencies to exact versions.\n- Improved documentation and removed redundant/duplicate trigger keywords and files.\n\nv3.0.0 | 2026-07-12T12:29:56.439Z | user\n\nv3.0: +4 features (vaccine efficacy, Bayesian, dose escalation, multiple endpoints), 18 test types, 3-step menu system, extended_functions.md\n\nv1.0.2 | 2026-07-12T11:07:53.695Z | user\n\nAdd Purpose section (bilingual), clarify skill positioning as clinical trial sample size & power expert with statistical design guidance\n\nv1.0.1 | 2026-07-12T10:36:14.583Z | user\n\nFix authors to medstatstar/phoe-zip, update homepage to github.com/medstatstar/ct-samplesize\n\nv1.0.0 | 2026-07-12T10:30:50.052Z | user\n\nInitial release: clinical trial sample size & power calculation, bilingual EN/CN, Python basic stats + R advanced designs, mandatory R code output\n\nArchive index:\n\nArchive v5.8.0: 68 files, 477531 bytes\n\nFiles: adapters/__init__.py (248b), adapters/bug_report.py (20622b), adapters/coze_client.py (60454b), adapters/coze_token_embedded.py (6773b), adapters/llm_loader.py (4638b), adapters/rendering.py (41071b), AGENTS.md (11358b), assets/icon.svg (3218b), CHANGELOG.md (249461b), config/config.json (422b), config/llm_key.py (389b), docs/ADVANCED_zh-CN.md (15558b), docs/ADVANCED.md (15522b), docs/ROADMAP.md (4287b), LICENSE (1089b), README_zh-CN.md (20979b), README.md (23608b), references/adaptive_simulator.md (8690b), references/backend_optimization_2026-09-11.md (4161b), references/batch_calls.md (3504b), references/bug_report_endpoint.md (3012b), references/cli_examples.md (15248b), references/data_format_guide.md (14653b), references/default_figures.md (8702b), references/drug_name_map.json (23396b), references/effect_size.md (1541b), references/examples.md (2397b), references/extended_functions.md (21223b), references/formulas.md (4041b), references/justification_templates.md (3555b), references/language_policy.md (2658b), references/menu.md (12900b), references/operation_sop.md (6633b), references/python_usage.md (3271b), references/rendering_rules.md (4745b), references/report_template.md (3572b), references/security_model.md (3755b), references/svg_editing.md (1567b), references/term_map.json (23195b), references/units.md (3748b), requirements.txt (453b), scripts/alloc_curve.py (49147b), scripts/assumption_block.py (9551b), scripts/classify_test.py (12501b), scripts/compute_backend.py (11072b), scripts/drug_name_resolver.py (5977b), scripts/excel_style.py (24154b), scripts/figure_kit.py (56492b), scripts/hypothesis_audit.py (27411b), scripts/i18n_messages.json (38864b), scripts/i18n_r_messages.json (3035b), scripts/i18n_skill_messages.json (24214b), scripts/i18n.py (36070b), scripts/justify_text.py (16403b), scripts/keyword_breadth.py (9756b), scripts/kw_lexicon.json (32482b), scripts/kw_localize.py (35924b), scripts/merge_spec.py (3756b), scripts/mult_alloc.py (7879b), scripts/office_to_md.py (18121b), scripts/param_aliases.py (11726b), scripts/r_libs.py (8104b), scripts/samplesize_power.py (77128b), scripts/source_guard.py (5915b), scripts/verify.py (33602b), skill-card.md (2519b), SKILL.md (25712b), _meta.json (132b)\n\nFile v5.8.0:SKILL.md\n\n---\r\nslug: ct-samplesize\r\ndisplayName: Clinical Trial Sample Size / 临床试验样本量专家\r\nname: ct-samplesize\r\ncn_name: 临床试验样本量专家\r\nversion: 5.8.0\r\ninvocable: true\r\nrequired_commands: [python]\r\nsummary: 为临床试验从业者提供的样本量与检验效能计算工具。本地无需安装 R，直接提供云端 R 计算服务（覆盖 49 种检验，并提供 SVG 出版级别图形）。自然语言驱动，默认回传完整 R 代码；默认按操作系统语言设定输出中文或英文（提示词可强制切换）。\r\nlicense: MIT\r\ndescription: \"Sample size and power calculation tool for clinical trial practitioners. No local R install needed — a cloud R compute service covers all 49 test types and returns publication-grade SVG figures. Natural-language driven; full reproducible R code is returned by default; default output in Chinese or English per OS language setting (prompt can force-switch). / 为临床试验从业者提供的样本量与检验效能计算工具。本地无需安装 R，直接提供云端 R 计算服务（覆盖 49 种检验，并提供 SVG 出版级别图形）。自然语言驱动，默认回传完整 R 代码；默认按操作系统语言设定输出中文或英文（提示词可强制切换）。\"\r\ntriggers:\r\n  - \"clinical trial sample size\"\r\n  - \"样本量计算\"\r\n  - \"clinical trial power\"\r\n  - \"检验效能计算\"\r\n  - \"临床试验 设计\"\r\n  - \"non-inferiority sample size\"\r\n  - \"equivalence sample size\"\r\n  - \"survival analysis sample size\"\r\n  - \"adaptive design\"\r\n  - \"group sequential design\"\r\n  - \"Bayesian clinical trial\"\r\nmetadata: { openclaw: { emoji: \"📊\" }, authors: [\"medstatstar\", \"phoe-zip\"], license: \"MIT\", tags: [clinical-trial, sample-size, power, coze, adaptive-design, bayesian, win-ratio], homepage: \"https://github.com/medstatstar/ct-samplesize\" }\r\npermissions:\r\n  scope: \"user-space-only\"\r\n  network: \"required\"\r\n  network_note: \"v5 requires the remote coze compute endpoint (CTSS_COZE_ENDPOINT, or CTSS_COZE_MOCK=1 for a local demo) — the published skill has no local compute fallback. Only trial-design parameters leave the machine (no patient data); every request also carries a hostname hash `query_origin` (sha256, for server attribution/rate-limit) and the OS-language-derived `locale`, and the skill version `skill_version` (read from the local SKILL.md, for per-version attribution of cloud usage). Outbound authorization gate: the public endpoint is pre-whitelisted in config/config.json auto_approve_endpoints (never prompts, but the assistant states what is sent on first use); user-custom endpoints trigger a one-time AUTH-BLOCK user confirmation before any data leaves the machine. Payloads are sanitized (PII stripped) before sending.\"\r\n  filesystem: \"writes figures to CTSS_OUTPUT_DIR (default ./outputs) and optional curve PNGs; otherwise read-only\"\r\n  data: \"no patient/external data leaves the boundary — only trial-design parameters plus the hostname hash (query_origin), the skill version (skill_version) and locale metadata are sent to the coze service\"\r\n\r\n---\r\n\r\n# Clinical Trial Sample Size\r\n\r\n## Published Application\r\n\r\n| Item | Value |\r\n|---|---|\r\n| Share link | `https://ct-samplesize.app.workbuddy.host/` |\r\n| appId | `wbapp_9K1dei1PydVQ66YmawCD3C` |\r\n| domainPrefix | `ct-samplesize` |\r\n| Deploy metadata | `adapters/workbench/app.config.json` |\r\n| Deployed as | Static site (`python -m http.server $PORT --bind 0.0.0.0`) |\r\n| Payload | `WorkBuddy/2026-09-14-14-39-40/deploy_ctss/static/index.html` |\r\n\r\n> **Re-publish rule**: always overwrite with the existing `appId` — the link must stay\r\n> `https://ct-samplesize.app.workbuddy.host/`. Never `createNewApp`. After deploy, assert the returned\r\n> `shareLink` equals the expected URL (see ct-base §13.5 dirty-binding red line). Last republished\r\n> 2026-09-26 (feedback two-stage fix).\r\n\r\n## Language\r\n\r\n- **English guide** → [README.md](https://github.com/medstatstar/ct-samplesize/blob/main/README.md) · **中文指南** → [README_zh-CN.md](https://github.com/medstatstar/ct-samplesize/blob/main/README_zh-CN.md)\r\n- Bilingual auto-switch: the answer language follows the user's question language (English question → English answer, Chinese question → Chinese answer).\r\n\r\n## Purpose\r\n\r\nThis skill provides clinical trial researchers with an easy-to-use, comprehensive sample size & power calculation tool. **The default authoritative engine is a remote coze R compute service** (rpact / TrialSize / PowerTOST and 20+ other packages — running server-side, so your machine needs **no local R**), covering all 49 test types. Results come in Chinese or English per the OS language setting (prompt can force-switch). Reproducible R code is returned by default (coze returns it on every analysis).\r\n\r\n---\r\n\r\n## Features\r\n\r\n| Capability | Description | Typical Scenario |\r\n|:---|:---|:---|\r\n| **① Sample size ⇄ Power (bidirectional)** | Solve n given target power, AND solve achievable power given fixed n. `--power` (forward) and `--nobs` (reverse) are mutually exclusive; covers all 49 types. | Sample size fixed, evaluate if power meets target |\r\n| **② Power curve** | Given a sample-size sequence, batch-compute and plot the **Power curve** (x=sample size, y=power), with a target-power reference line. | Sample-size sensitivity analysis, protocol reporting |\r\n| **③ Sample-size curve** | Given a power-target sequence, batch-compute and plot the **sample-size curve** (x=target power, y=required n). | Resource planning, feasibility assessment |\r\n| **④ Deterministic NL pre-route (zero-LLM)** | `--nl \"<natural language>\"` runs a local zero-LLM deterministic detector that identifies `--test` and extracts params (power 80%→0.8, rate 70%→0.7, \"enroll 30\"→reverse-solve power, etc.), emitting a strong signal for the coze request; when confidence is low / params incomplete it prints a structured prompt and **never silently mis-params** — the local agent then asks the user for the missing test/params (≤2 rounds, then defaults); **raw NL text is never sent to coze** (the workbench is **deterministic-first** — `classify_test` + `param_aliases`, identical to conversation mode; the LLM fallback in `adapters/workbench/nl_llm.py` defaults to the family backend model LongCat-2.0 per ct-base §12 (key via `load_llm_key()`: `LONGCAT_API_KEY` env > obfuscated `config/llm_key.py`; `CTSS_NL_ENDPOINT` overrides to any OpenAI-compatible model) and may only propose a test when rules fail — never override a rule-identified test; the coze compute endpoint has no NL/LLM path). Logic in `scripts/classify_test.py` + `scripts/param_aliases.py`; per-test contract baselines in `tests/coze_cases/` (`tests/coze_cases_regression.py` offline regression), 49-test enumeration in `adapters/coze/coze_contract.md`. | User phrases it colloquially, e.g. \"non-inferiority survival trial, NI margin 1.25…\" |\r\n\r\n- ②③ curve mode: list `\"20,40,200\"` or auto-seq `\"20:20:200\"` (start:step:stop); overlay multiple effect-size curves for sensitivity (continuous/survival solvers; proportion solvers plot the single p1/p2 series); returns the figure (SVG default per the ct-* uniform figure spec, PNG fallback) **plus the numeric series as machine-readable stats (x/y arrays)**. Full parameters & 49-test examples → `references/cli_examples.md`.\r\n- **Specialized curve modes (`--effect_seq` / `--dist_plot` / `--power_time_seq` / `--heatmap`, added 2026-08-28):** effect-axis / H0–H1 overlap / follow-up-power / 2-D sensitivity scans for the 9 curve solvers; full parameters & 49-test examples → `references/cli_examples.md`.\r\n- **★ Default figures (v5.6 + 2026-08-28):** when no figure is requested, the R engine auto-attaches the full set for the 9 curve solvers (curves + dist-overlap + heatmap) and the survival follow-up–power curve (`type` field + bilingual `caption`); all figure generation moved to the coze side — coze R (`coze_figure_layer.R`) is the primary plotter, `figure_kit.py` the coze-internal fallback, the local CLI a **thin client** consuming coze-returned `figures[]`. **Zero new R packages**. Opt out via any explicit figure flag / `--dry-run`; see [Default Figures (v5.6)](#default-figures-v56) and `references/default_figures.md`.\r\n\r\n---\r\n\r\n## Interaction — Triage first\r\n\r\nBefore answering, triage the request into the four-level difficulty **Simple / Middle / Complex / Vague**:\r\n- **Simple** (test already named, params mostly given) → answer directly, **no menu**.\r\n- **Middle** (single-point but deep — ICH guidance detail, statistical parameter, compliance gray zone, needs 3–4 points) → still answer **directly, no menu** (same path as Simple; mark `difficulty = \"middle\"` for a richer multi-point answer). When Simple vs Middle is unclear, prefer **Middle**.\r\n- **Complex** (pick test type / design family / many params) → show the **routing menu** below (**the `## Quick Menu` is for the Complex branch only**).\r\n- **Vague** (\"not sure which test to use\") → **bounded grill-me** (branch-by-branch probing), do **not** dump the menu. **Hard cap: ≤3 rounds** (on reaching the cap with the test still undecided, **converge with the accumulated question profile** — pick the best-fit test family and confirm). Each round ask 1–3 focused questions with a recommended default; accumulate confirmed fields into a **question profile**; when the test is locked, **echo a \"needs portrait + recommended test + missing params\" summary for confirmation** before computing. (This 3-round cap targets locking the test; the global missing-parameter cap is **2 rounds then use defaults** — different dimensions, no conflict.)\r\n\r\n**Routing gate (audit follow-up — avoid accidental remote compute):** a **remote coze compute** (data leaves the machine) happens **only** when the user's intent is explicitly a sample-size / power / curve **calculation**. General consulting — \"help me figure out my trial design\", methodology questions, ICH guidance, \"what test should I use\" — must be answered **locally without sending anything**, and may use the menu / grill-me flow. Do not fire a coze request on vague or advisory phrasing; ask for the calculation intent first.\r\n\r\n## Cross-turn Continuity (mandatory)\r\n\r\n> **Runtime is stateless.** The coze R engine re-supplies `test`+`params` each call and never persists prior fields. Semantic drift (effect/α/power/n silently changing) = highest-risk failure for a stateless remote.\r\n\r\n**Hard rules** (full rules below (Cross-turn Continuity); minimal unit = `{test, effect, alpha, power, solve, side, sd}`, `—` = not-yet-known):\r\n1. **Echo a `## 当前分析设定：` block after every calculation (mandatory):** `## 当前分析设定： test=ttest_ind | effect(d)=0.5 | alpha=0.05 | power=0.8 | solve=n | side=two | sd=1.0 | n=— | ratio=—`. No field omitted (`—` placeholder). `solve=n` solves n given power; `solve=power` reverses; `side=two/one_greater/one_less`.\r\n2. **On follow-up, change only the changed fields:** read the most recent `## 当前分析设定：` block, override only the changed field, inherit the rest verbatim, then send to coze.\r\n3. **Deterministic merge (default path, not optional):** every follow-up **MUST run** `merge_spec.py` for a lossless merge, then send the merged spec to coze — never assemble params from LLM memory alone. `echo '{\"prev\":{...},\"cur\":{\"power\":0.9}}' | python scripts/merge_spec.py` (dev: `scripts/merge_spec.py`). If `missing_required` is non-empty, clarify first. (The `compute` payload also carries `resolved_spec`, a full snapshot — additive, landed.)\r\n\r\n> Red line: ct-samplesize's coze is a **stateless remote compute**; continuity MUST be solved locally — the remote cannot help unless you actively send history. `merge_spec.py` is the local **deterministic merger** (code-fixed, LLM-executed), not a fragile classifier — upholds family red line 4.\r\n\r\n## Batch-call governance (v5.7, must-read)\r\nMandatory constraints (curve-already-contains-single-point; batch-grid-submit; trim-envelope via `build_params`) + Feishu-backend evidence + outbound envelope guard + local `--batch-file` → `references/batch_calls.md`.\r\n\r\n## Quick Menu — two-level routing (level-1 only here; level-2 in `references/menu.md`)\r\n\r\n> Authoritative layered menu: [`references/menu.md`](references/menu.md) · CLI examples & bidirectional solve: [`references/cli_examples.md`](references/cli_examples.md) · Operation SOP: [`references/operation_sop.md`](references/operation_sop.md).\r\n>\r\n> **Two-level routing rule (per Type-Compute, do NOT dump the full test list):** on a Complex request, first show **only this level-1 summary** (6 endpoint categories + high-frequency design families). After the user picks a category, go to `references/menu.md` **Part 1** for that category and show the **level-2 sub-list** (the specific `--test` options). Never present all ~49 tests in one screen.\r\n\r\n**Level 1 — endpoint categories:**\r\n- ① **Continuous** (means) · ② **Binary / Proportions** (rates, OR/RR, NI/BE) · ③ **Count / Rates** (Poisson) · ④ **Survival / Time-to-event** (logrank, HR, one-sample) · ⑤ **Diagnostic / Method comparison** (ROC, Bland-Altman) · ⑥ **Special / Advanced designs** (group-sequential, adaptive, Bayesian, MAMS, win-ratio, cluster …)\r\n\r\n**Level 1 — high-frequency design-family entries** (non-exclusive; full list in `references/menu.md` Part 2): Group-Sequential · Adaptive · Equivalence / Non-inferiority / BE · Bayesian · Dose-escalation · MAMS · Historical control · Vaccine · Win-statistics · Cluster / Multiple endpoints\r\n\r\n> ③ **Can't decide?** → say \"explain the differences between these choices in detail\", and I'll clarify the clinical/statistical meaning before you choose. (Family-standard wording, verbatim.)\r\n\r\n> The menu is a *navigation aid*, not a strict taxonomy: the same test is reachable from multiple categories (e.g. `gsd_survival` from both ④ Survival and the Group-Sequential index). Still unsure where to start? Use **Part 0** in `references/menu.md` — find your test by *research question*, no jargon needed.\r\n\r\n**Advanced:** `--test adaptive_simulate` empirically validates adaptive / group-sequential designs (power, type I error, expected N) — full guide → [`references/adaptive_simulator.md`](references/adaptive_simulator.md). `--verify` (default OFF) re-simulates an **analytic** solution with an **independent** Monte-Carlo engine (checks empirical power ±2 pp / type-I error ±0.5 pp; takes only the n as input, so a wrongly-derived n is caught) — supports `ttest_* / proportion_two / survival(log-rank) / group_sequential / adaptive_reestimate`; reports MC 95% CI, returns `INCONCLUSIVE` rather than a false PASS. Pure local, no network. `--audit` (added 2026-09-29, planning layer) grades every design assumption **known / weak / unknown / missing** (with fabrication-signature heuristics + `--evidence-source` promotion), maps the test into 7 design-logic families with self-consistency checks, and emits **fallback/contingency plans** per weakest assumption; exits without computing; complements (not replaces) `--show-assumptions`. Pure local (`scripts/hypothesis_audit.py`). `--mcid Δ --sd S [--mcid-source …]` (J1) is a clinically-worded alias of the Δ/sd conversion channel (d = MCID/SD, echo + audit linkage); `--justify` (J2) appends an **IRB/SAP-ready bilingual justification paragraph** — hidden by default: the paragraph text renders software as `R <ver> + rpact/TrialSize <ver>` (versions from the result envelope; no cloud/local wording; unknown versions render as fill-in placeholders), and after a successful single computation the CLI prints a one-line offer — **when you see that offer, ask the user whether they want the document paragraph; generate it only on their yes (re-run with `--justify`)**. Skeleton = CONSORT-SPIRIT Item14/DELTA2 Box4 + CDE《样本量估计指导原则(试行)》2024-12-23; placeholders must be filled by the investigator — anti fake-precision. Details → [`references/justification_templates.md`](references/justification_templates.md). Pure local (`scripts/justify_text.py`).\r\n\r\n---\r\n\r\n## Requirements\r\n\r\n| Requirement | Details |\r\n|:---|:---|\r\n| **coze compute endpoint** | **Production default.** Set `CTSS_COZE_ENDPOINT` (or `COZE_ENDPOINT`) to the coze R service; covers all 49 tests. For a no-network demo, set `CTSS_COZE_MOCK=1`. |\r\n| **Python** | ≥ 3.8, **stdlib only** (argparse / json / urllib). The v5 refactor removed the local pure-Python fallback and all third-party compute deps (statsmodels / numpy / scipy are no longer required). No local R required. |\r\n| **R (dev / optional)** | **Not shipped in the published skill.** The coze R engine source is maintained in the coze-synced backend directory (excluded from the publish package). The legacy local-R backend and R templates are kept for offline dev / contribution only — **the v5 `select_backend` no longer routes to them**; they are not part of the published skill. |\r\n\r\n---\r\n\r\n## ⚠️ Safety\r\n\r\n- **No local R / shell is ever executed.** The published skill never runs R or a shell on your machine. The default engine is the remote **coze** compute service: only trial-design parameters (never patient data) are sent, and results come back as numbers + optional figures — inherently safe (stateless compute, no local code execution).\r\n- **SAFE PREVIEW is the default for inspection.** `--dry-run` prints the exact request envelope (test, params, mode) that *would* be sent to coze, without sending anything. `--show-code` reveals the coze request JSON (the R source coze used is included in every result by default). The legacy `--yes` gate applies only to the optional local-R dev backend (offline dev only).\r\n- **First-use outbound disclosure (audit follow-up):** even though the public coze endpoint is pre-whitelisted (never prompts), the assistant MUST state on first outbound use in a session — in one line: \"This will send your trial-design parameters plus a hostname hash (query_origin), your skill version (skill_version) and locale to the cloud service https://ct-samplesize.coze.site/run for computation — proceed?\" (localized zh version in `references/security_model.md`). Custom endpoints still trigger the one-time AUTH-BLOCK confirmation. **Output for reference only; validate before regulatory submissions.**\r\n\r\n### Security model (transparent disclosure)\r\n\r\n> Full disclosure table (remote compute / server-side R / output / network / outbound gate / filesystem), upload confidentiality, and the natural-language outbound guidance → [`references/security_model.md`](references/security_model.md). Key guarantees: no local R/shell; SAFE PREVIEW default; only trial-design parameters ever leave the machine.\r\n\r\n---\r\n\r\n## User-Uploaded Documents\r\n\r\nThis skill is **parameter-driven** (design params via CLI / natural language). When the user uploads a document (protocol / SAP / design brief as `.docx` / `.pptx` / `.pdf` / `.doc`), **convert it to md/text first**, then extract the design parameters — the coze endpoint is a plain-text JSON contract and does **not** accept attachments. Converter: shared **`scripts/office_to_md.py`** (stdlib-only, single parser for docx+pptx):\r\n\r\n| Uploaded format | Handling |\r\n|---|---|\r\n| `.docx` / `.pptx` | `python scripts/office_to_md.py <file>` → md (pptx sectioned by `### Slide N`) |\r\n| `.pdf` / `.doc` / scanned | env `pdf` skill (OCR prompt) / word-reader / text-version prompt — never hand-write a parser |\r\n\r\n**🔔 User notice before ANY conversion (show this exact notice first):**\r\n> ⚠️ Every uploaded document is converted to **md** for processing; **PPT conversion tends to lose substantial information** (images, layout, animations, charts, and other non-text elements). We recommend you **convert to md and review the content yourself** before asking, so key details are not lost.\r\n\r\n**Confidentiality:** the skill does **not** judge data confidentiality — the document is converted as-is; **only the extracted design parameters** (test, effect, α, power, n …) are ever sent to coze; the raw document md is used **locally for parameter extraction only** and never forwarded. If the user requires data-not-leaving, guide them to keep computation fully local (extract params and compute manually, or use the offline dev backend) — never send document content to coze.\r\n\r\n---\r\n\r\n## Implementation\r\n\r\n**Bidirectional solve:** `--power` (default) solves required `n` given target power; `--nobs N` reverses to achievable power given fixed `n` (mutually exclusive, `--nobs` wins). Default = **SAFE PREVIEW**: `--dry-run` prints the coze request envelope without sending; `--show-code` reveals it (and, with `CTSS_RETURN_R_CODE=1`, the R source coze used); no `--yes` needed for coze (stateless remote compute). Full CLI examples (all 49 tests, reverse-solve, curve mode) → `references/cli_examples.md`; data format → `references/data_format_guide.md`.\r\n\r\n**Common params:** `--side one|two` (default `two`, test direction); `--sd FLOAT` (optional, auto-computes Cohen's d = Δ/sd; omitted ⇒ `--effect` is d directly).\r\n\r\n**Curve mode:** `--n_seq`/`--power_seq`/`--plot_effects`/`--effect_seq`/`--dist_plot`/`--power_time_seq`/`--heatmap` — see Features. **9 tests support curves** (`.curve_solvers`: ttest_ind/paired/one, anova, proportion_one/two, survival, equivalence, be_tost); `--dist_plot` covers `ttest*/proportion*/survival`; `--power_time_seq` survival-only; others return \"curve not supported\".\r\n\r\n> **Architecture & security:** orchestration (`scripts/samplesize_power.py`) contains **no R code**; `ComputeBackend` (`scripts/compute_backend.py`) routes to `CozeBackend` (default authoritative, server-side R) — the only backend in v5. All R logic lives in the coze-synced, publish-excluded backend directory. Every user string reaching server-side R is validated against a strict allowlist. History → `CHANGELOG.md`.\r\n\r\n### Workbench\r\n\r\nA local web UI covering the full flow \"input → results → figure-option control → follow-up questions\": `adapters/workbench/` (backend `server.py` is a stdlib-only `http.server`, frontend `workbench.html` is a single zero-dependency file). The form schema is reflected at runtime from argparse + `_contract_index.json` (49 tests / 178 params, zero-maintenance); follow-up questions reuse the deterministic merge (`merge_spec`). Launch defaults to the **live coze endpoint** (not MOCK — MOCK returns fake results). On Windows hosts with a stale system `HTTP(S)_PROXY` in the registry, strip the proxy env (`HTTPS_PROXY= HTTP_PROXY= ... NO_PROXY=*`) or urllib cannot reach coze. See `adapters/workbench/README.md` for the exact launch command and endpoints.\r\n\r\n---\r\n\r\n## Figure Output & Rendering\r\n\r\nAll figures follow the **uniform SVG spec shared across the ct-* family** (same pipeline as `meta-analysis`). The coze endpoint emits all figures; the conversation stream does **NOT** inline SVGs — presentation is delegated to the local HTML aggregated report (`render_html_report`, stats + SVGs + R script). No hand-redraw. Details → [`references/rendering_rules.md`](references/rendering_rules.md). **Default Figures (v5.6):** every method produces ≥1 figure, all on the coze side (8 default kinds, effect ±20 % sensitivity band, zero new R packages). The local allocation-ratio filter (v5.7.1) shows `alloc_suite` only when `--ratio != 1`. Full spec → [`references/default_figures.md`](references/default_figures.md).\r\n\r\n---\r\n\r\n## Formulas, Reports & Errors\r\n\r\n**Formulas:** `references/formulas.md` (all 49 types, incl. independent t / Schoenfeld survival / Cox-with-covariate / Cluster DEFF) | **Full functions:** `references/extended_functions.md` | **Common error:** coze endpoint not configured → set `CTSS_COZE_ENDPOINT` (real) or `CTSS_COZE_MOCK=1` (demo)\r\n\r\n## Bug Reporting\r\n\r\nAgent behavior only; implementation → `adapters/bug_report.py`, protocol → `references/bug_report_endpoint.md`.\r\n\r\n- **Trigger (strong signal, max 1 proposal/session):** unexpected non-zero exit / engine or compute error / user explicitly questions the result — **and** the same operation was retried ≥1. Weak signal (repeated tuning) never triggers. Explicit user request (e.g., \"report a bug\") also triggers, without the once-per-session limit.\r\n- **Two-stage confirmation:** ① propose-with-preview — show the bilingual `confirm_prompt` **with** the full sanitized report (`render_report_text`); user may add a `description` (re-render & re-show before consent) → ② on explicit consent, `send_to_endpoint` (action=report, endpoint `https://ct-bugreport.coze.site/run`). If declined, never re-propose this session.\r\n- **Sanitization is hard:** report carries only the 11-key whitelist — never raw data or subject records. `description` is the only free-text field, **user-reviewed**; hard boundary: no identifiable person/institution/subject info. If the session had **no** cloud call, `save_local_report()` writes locally (data never leaves the machine).\r\n- **Client-only:** send `report` only. Governance actions (get/update/download/delete) are reserved for `ct-update`; never call them here.\r\n\r\n---\r\n\r\n## Related skills (ct- library, agent chains as needed)\r\n\r\n- **Upstream (context)**: `ct-registry` (via `ct-pipeline` public-intel orchestration) · **Downstream**: `ct-protocol` (protocol skeleton) → `ct-ecrf` (CRF + SDTM mapping spec) · **Same category (design)**: `ct-protocol` / `ct-ecrf` / `ct-eligibility` · **Public-intel (Tier B)**: `ct-pipeline` (dispatches `ct-registry` / `ct-safety` / `ct-literature`)\n\nFile v5.8.0:README.md\n\n# Clinical Trial Sample Size (ct-samplesize)\r\n\r\n- **English guide** → [README.md](https://github.com/medstatstar/ct-samplesize/blob/main/README.md) · **中文指南** → [README_zh-CN.md](https://github.com/medstatstar/ct-samplesize/blob/main/README_zh-CN.md)\r\n\r\n<div align=\"center\">\r\n  <img src=\"assets/icon.svg\" alt=\"ct-samplesize logo\" width=\"240\" height=\"240\">\r\n</div>\r\n\r\n> **Works without installation:** If you'd rather not install and just want to quickly use this skill's basic features, you can also visit the ct-series unified web portal **https://ct.medstatstar.com** directly.\r\n\r\n> **Easy-to-use Clinical Sample Size & Power Calculator for Clinical Researchers**\r\n>\r\n> You don't need to code or memorize commands — just describe your trial design in **plain language inside a chat**, and the skill performs **49** professional sample-size & power calculations for you. The default authoritative engine is a **remote coze R compute service** (rpact, TrialSize, PowerTOST and 20+ other packages running server-side, so your machine needs **no local R**; the published skill has **no local compute fallback**). Results come in Chinese or English per your OS setting (force-switchable via prompt). By default the skill shows a **SAFE PREVIEW** of the exact request it would send to coze — nothing leaves your machine until you confirm; full R code can be returned on request.\r\n\r\n---\r\n\r\n## Who This Is For\r\n\r\nThe `ct-*` clinical-trial skill family covers the whole clinical-trial lifecycle. ct-samplesize targets three groups who need **defensible sample-size / power numbers across 49 designs**:\r\n\r\n- **Clinical-trial practitioners at pharmaceutical companies** — sponsors, CROs, and medical / statistical / regulatory roles: quick, auditable n / power for protocols, SAPs, feasibility.\r\n- **Clinicians and nurses who design or run trials**: estimate sample size when drafting protocols or feasibility assessments.\r\n- **Medical students who want to learn clinical-trial methodology**: exploring design families (group-sequential, adaptive, Bayesian, non-inferiority…).\r\n\r\nThis tool only takes aggregate design parameters — never patient-level data.\r\n\r\n---\r\n\r\n## 1. How to Use It in a Chat (the Core)\r\n\r\nct-samplesize is a **conversational skill**: you simply tell the assistant your trial design in natural language — no commands, no parameter names to remember. As a WorkBuddy skill it **auto-loads with no extra installation**.\r\n\r\nBelow are 6 real conversational examples ordered by common entry point — from \"not sure which test\" to specific designs. Each gives **\"You say\"** (a copy-ready natural-language input), a sketch of **\"The assistant replies\"**, plus how to get the actual number.\r\n\r\n### Example 1 · Not sure which test (most common opening)\r\n**You say:**\r\n> I want a sample-size calculation but I'm not sure which test to use — help me choose the right one\r\n\r\n**Assistant replies (sketch):**\r\n> Sure — let's pin down your trial design first. I'll ask 1–3 focused questions per round, each with a recommended default — confirm or adjust.\r\n>\r\n> **Round 1 (2 questions):**\r\n> 1. What type is your **primary endpoint**? — continuous (e.g. BP difference) / binary (e.g. response rate) / time-to-event (e.g. OS) / other?\r\n> 2. Is it **parallel-group** or **crossover/paired**? (most designs are parallel — default to that unless you say otherwise)\r\n>\r\n> *(You answer…)*\r\n>\r\n> **Round 2 (2 questions):**\r\n> 3. What do you want to show — **superiority**, **non-inferiority**, or **equivalence**?\r\n> 4. If the endpoint is binary/rate, the **effect expression** is the key fork: **absolute risk difference** (control 60% vs treatment 75%, a 15pp gap → `proportion_two`) or **OR / RR** as the primary effect (OR=2.0 → `odds_ratio`, RR=1.5 → `risk_ratio`)? The sample-size formulas differ substantially; an OR usually needs more subjects.\r\n>\r\n> *(Once the test and effect expression are locked, I'll echo a **needs portrait + recommended test + missing params** summary for your confirmation, then compute — no 49-test menu dumped on you in the meantime.)*\r\n\r\n**📌 Note:** When you say \"not sure which test\", the assistant uses **branch-by-branch probing** to clarify your needs, instead of dumping the 49-test menu. Once clarified, it moves to computation.\r\n\r\n### Example 2 · Two-means comparison (most common)\r\n**You say:**\r\n> Calculate sample size for two independent means, effect size d=0.5, power 80%, two-sided α=0.05\r\n\r\n**Assistant replies (sketch):**\r\n> Here is the sample-size calculation for a two-sample t-test (effect size d=0.5, power=0.8, two-sided α=0.05).\r\n> You need about **64 per group** (128 total).\r\n> Since this is a simple two-group solve, the assistant also auto-attaches a **sample-size curve** (n per group vs target power 0.6–0.95, SVG inline & editable); give a fixed n instead and you get the **power curve** (power vs n) automatically.\r\n> (Safe preview by default: the exact coze request envelope is shown, nothing sent or computed — say \"please compute directly\" to actually run it.)\r\n\r\n**📌 Get the actual number:** By default the skill shows a **SAFE PREVIEW** — the exact coze request envelope, nothing sent or computed. Say **\"please compute directly\"** and the assistant will really run it and give the number (on the default coze stateless engine this natural-language trigger is what fires the compute; **no `--yes` needed** — the legacy `--yes` flag applies only to the optional local-R dev backend, see Section 4, \"Safe Preview\").\r\n\r\n### Example 3 · Two-group proportion\r\n**You say:**\r\n> Control response 20%, treatment 35%, two-group proportion chi-square, α=0.05 two-sided, power=0.8\r\n\r\n**Assistant replies (sketch):**\r\n> Two-group proportion comparison (control 20% vs treatment 35%, χ², α=0.05 two-sided, power=0.8): you need about **137 per group** (274 total). A **sample-size curve** is auto-attached; ask for a power-vs-n curve at any fixed n if needed.\r\n\r\n**📌 Get the actual number:** By default the skill shows a **SAFE PREVIEW** — the exact coze request envelope, nothing sent or computed. Say **\"please compute directly\"** and the assistant will really run it and give the number (on the default coze stateless engine this natural-language trigger is what fires the compute; **no `--yes` needed**).\r\n\r\n### Example 4 · Survival endpoint with interim\r\n**You say:**\r\n> Design a survival trial with 1 interim analysis, HR=0.75, 1:1 randomization, power 80%, and **plot the power curve** (n vs power)\r\n\r\n**Assistant replies (sketch):**\r\n> Parsed: time-to-event endpoint, HR=0.75, 1:1 randomization, power 80%, 1 interim analysis (group-sequential / interim framework by default).\r\n> By default the skill shows a **SAFE PREVIEW** — the exact coze request envelope (test, params, mode) is displayed, nothing sent or computed.\r\n> Say \"please compute directly\" to trigger the real calculation: it returns the required sample size (events d and total n) and auto-attaches your requested **power curve** (power vs n, SVG inline & editable).\r\n\r\n**📌 Get the actual number:** SAFE PREVIEW by default (exact envelope shown, nothing sent or computed). Say \"please compute directly\" to really run it and get the number + curve inline (stateless remote engine, no `--yes` needed).\r\n\r\n### Example 5 · Non-inferiority / Bioequivalence (curve mode)\r\n**You say:**\r\n> Non-inferiority design, margin=0.1, control rate 85%, treatment 80%, power 80%, and **draw the sample-size curve** (n vs target power)\r\n\r\n**Assistant replies (sketch):**\r\n> Parsed as non-inferiority (margin=0.1, control 85% vs treatment 80%, power 80%). By default SAFE PREVIEW; say \"please compute directly\" to get the per-group n and an auto-attached **sample-size curve** (n vs target power, SVG inline). Bioequivalence (BE) is the same pattern: theta0=0.95, CV=25%, 2×2 crossover also auto-attaches a sample-size curve.\r\n\r\n**📌 Get the actual number:** SAFE PREVIEW by default (exact envelope shown, nothing sent or computed). Say \"please compute directly\" to run it and get the number + curve inline.\r\n\r\n### Example 6 · Test selection / design-family choice (popup menu)\r\n**You say:**\r\n> Compare two antihypertensives on office systolic BP, parallel-group, power 90%. But I haven't decided superiority vs non-inferiority, and I'm not sure whether to add an interim analysis.\r\n\r\n**Assistant replies (sketch):**\r\n> The endpoint (continuous · office SBP) and design (parallel) are clear. Two choices remain — here's a menu to help you decide:\r\n>\r\n> **① What do you want to show?**\r\n> - (a) Superiority: new drug lowers BP more than control → `ttest_ind` (superiority)\r\n> - (b) Non-inferiority: not worse than control, margin up to you → `non_inferiority`\r\n>\r\n> **② Add an interim analysis?**\r\n> - (a) No, fixed sample size → plain t-test\r\n> - (b) Yes, 1–2 interims with early stopping → `group_sequential` family\r\n>\r\n> **③ Can't decide?** → Say \"explain the differences between these choices in detail\" and I'll clarify the clinical/statistical meaning before you choose.\r\n>\r\n> Pick your preferences for ①–②, or choose ③ to hear the explanation, and I'll lock the test and move to parameter completion / computation.\r\n\r\n**📌 Note:** When you've **named the test type but are stuck on \"which option / design family\"** (e.g. superiority vs non-inferiority, with/without interim), the assistant **pops a routing menu** to confirm step by step — instead of deciding for you or dumping the full 49-test menu. The menu also offers an \"explain the differences\" option — when you're unsure, it explains before you decide. The full classification tree is in [`references/menu.md`](references/menu.md).\r\n\r\n> 💡 **Tip:** Most tests need only three things — effect size (or rate / HR) + power + α. Anything you omit (e.g. two-sided α=0.05, 1:1 randomization, follow-up) is filled with sensible defaults. It's fine to be incomplete — the assistant will tell you what's missing.\r\n\r\n---\r\n\r\n## 2. What You Can Compute — 49 Test Scenarios\r\n\r\nTests are grouped by **endpoint type** (6 categories below). Each row gives the typical **clinical scenario** and a line you can **copy verbatim** under \"Try saying\". The same test may *also* be reached from a **design-family cross-index** (group-sequential, adaptive, equivalence / non-inferiority, Bayesian, dose-escalation, MAMS, historical control, vaccine, win-statistics …) — see [`references/menu.md`](references/menu.md).\r\n\r\n> The underlying R engine runs **server-side on coze** (rpact / TrialSize / PowerTOST and 20+ other packages …); the published skill ships no R locally. See Section 5 \"Advanced Reference\" for the architecture note — ordinary users don't need to care.\r\n\r\n### ① Continuous\r\n| Test | Clinical Scenario | Try saying in chat |\r\n|:---|:---|:---|\r\n| `ttest_ind` | Two-means comparison (parallel) | \"Two-group mean comparison, d=0.5, power 0.8\" |\r\n| `ttest_paired` | Paired t / 2×2 crossover | \"Paired design sample size, effect 0.5\" |\r\n| `ttest_one` | One-sample vs known mean | \"One-sample test, difference from known mean 0.5\" |\r\n| `anova` | Multi-group (k groups) | \"3-group ANOVA, effect size f=0.25\" |\r\n| `equivalence` | Equivalence (means) | \"Mean equivalence, margin=2, effect 1\" |\r\n| `mixed_model` | Repeated measures / longitudinal (power given n) | \"Repeated-measures power, n=100, effect 0.5\" |\r\n\r\n### ② Binary / Proportions\r\n| Test | Clinical Scenario | Try saying in chat |\r\n|:---|:---|:---|\r\n| `proportion_two` | Two-group rate (chi-square) | \"Control 20% treatment 35%, two-group rate comparison\" |\r\n| `proportion_one` | Single-group rate | \"Single-group rate test, expected 30%\" |\r\n| `proportion_paired` | Paired rate (McNemar) | \"Paired rate comparison McNemar, p1=0.7 p2=0.5\" |\r\n| `odds_ratio` | Odds ratio | \"Sample size for OR=2, control rate 50%\" |\r\n| `risk_ratio` | Risk ratio (RR) | \"Sample size for RR=1.5, control rate 50%\" |\r\n| `non_inferiority` | Non-inferiority (rate) | \"Non-inferiority, margin=0.1, control 85% treatment 80%\" |\r\n| `superiority_margin` | Superiority by margin | \"Superiority test, margin 0.05\" |\r\n| `be_tost` | Bioequivalence (TOST) | \"BE sample size, theta0=0.95, CV=25%\" |\r\n| `vaccine_efficacy` | Vaccine efficacy | \"Vaccine efficacy, control VE=0.02 treatment 0.005\" |\r\n| `gsd_proportion` | Group-sequential two proportions | \"Group-sequential two proportions, 1 interim, p1=0.7 p2=0.5\" |\r\n\r\n### ③ Count / Rates\r\n| Test | Clinical Scenario | Try saying in chat |\r\n|:---|:---|:---|\r\n| `poisson` | Poisson rate | \"Two-group rate comparison, λ1=0.05 λ2=0.03\" |\r\n| `recurrent_events` | Recurrent events (Andersen-Gill) | \"Recurrent-event sample size, control rate 1.0\" |\r\n| `gsd_poisson` | Group-sequential Poisson | \"Group-sequential Poisson rate\" |\r\n\r\n### ④ Survival / Time-to-event\r\n| Test | Clinical Scenario | Try saying in chat |\r\n|:---|:---|:---|\r\n| `survival` | Survival (simplified logrank) | \"Survival analysis, HR=0.75, power 0.85\" |\r\n| `survival_exact` | Survival (exact) | \"Exact survival sample size, HR=0.75, accrual 12mo\" |\r\n| `ni_survival` | Non-inferiority survival | \"Non-inferiority survival, HR margin=1.25\" |\r\n| `survival_equivalence` | Survival equivalence (TOST / log-HR) | \"Survival equivalence, margin=1.25\" |\r\n| `survival_superiority` | Survival superiority w/ margin | \"Survival superiority, margin 0.8\" |\r\n| `cox_covariate` | Cox regression w/ covariate R² | \"Cox regression sample size, HR=2, R²=0.3\" |\r\n| `survival_one_sample` | One-sample exponential survival | \"One-arm survival, median 12 vs 18\" |\r\n| `competing_risks` | Competing risks (cum. incidence) | \"Competing-risk sample size, CIF 0.2 vs 0.1\" |\r\n| `survival_historical` | Historical-control logrank | \"Historical-control survival, historical median 12 new 18\" |\r\n| `gsd_survival` | Group-sequential logrank | \"Group-sequential survival, 1 interim, HR=0.7\" |\r\n| `gsd_hazard` | Group-sequential HR | \"Group-sequential HR, HR=0.7\" |\r\n| `gsd_survival_sim` | Group-sequential logrank — Monte-Carlo | \"Group-sequential survival simulation, 2 interims\" |\r\n| `gsd_hazard_sim` | Group-sequential HR — Monte-Carlo | \"Group-sequential HR simulation\" |\r\n\r\n### ⑤ Diagnostic / Method comparison\r\n| Test | Clinical Scenario | Try saying in chat |\r\n|:---|:---|:---|\r\n| `roc` | ROC curve / diagnostic trial | \"ROC curve sample size, AUC 0.5→0.75\" |\r\n| `bland_altman` | Bland-Altman method comparison | \"Bland-Altman sample size, SDdiff=5, margin 2.5\" |\r\n\r\n### ⑥ Special / Advanced designs\r\n| Test | Clinical Scenario | Try saying in chat |\r\n|:---|:---|:---|\r\n| `group_sequential` | Group sequential / interim | \"Group-sequential design, 2 interims, Pocock\" |\r\n| `adaptive` | Adaptive design | \"Adaptive design, 2 stages\" |\r\n| `adaptive_simulate` | Adaptive design — Monte-Carlo | \"Adaptive design Monte-Carlo simulation\" |\r\n| `bayesian` | Bayesian design | \"Bayesian design, control 0.3 treatment 0.15\" |\r\n| `dose_escalation` | Dose escalation (Phase I) | \"Phase I dose escalation, 5 doses, DLT 0.33\" |\r\n| `mams` | Multi-arm multi-stage (MAMS) | \"MAMS, 3 arms 2 stages\" |\r\n| `dunnett` | Dunnett multiple comparison | \"Dunnett, 3 groups control 50\" |\r\n| `win_ratio` | Win-Ratio composite endpoint | \"Win-Ratio sample size, WR=1.5\" |\r\n| `must_win` | Must-Win / co-primary endpoints | \"Co-primary endpoints 3, correlation 0.5\" |\r\n| `historical_controls` | Historical control borrowing | \"Historical control borrowing, historical response 15/100\" |\r\n| `conditional_power` | Conditional power / SSR | \"Conditional power, interim effect 0.2\" |\r\n| `assurance` | Bayesian assurance | \"Assurance calculation\" |\r\n| `multiple_endpoints` | Multiple/compound endpoints | \"Multiple-endpoint sample size, correlation 0.5\" |\r\n| `mediation` | Mediation effects | \"Mediation sample size\" |\r\n| `cluster` | Cluster-randomized | \"Cluster randomized, ICC=0.05, 30 per cluster\" |\r\n\r\n---\r\n\r\n## 3. First-Time FAQ\r\n\r\n**Q: I only gave effect size and power, no other parameters — will it still compute?**\r\nA: Yes. Most tests need only three things — effect size (or rate / HR) + power + α. Omitted parts (two-sided α=0.05, 1:1 randomization, follow-up …) are filled with sensible defaults; if something truly required is missing, the assistant will ask.\r\n\r\n**Q: Is the n in the result per group or total?**\r\nA: By default it's **per group**; paired / crossover designs report per-sequence, and survival often reports total events needed. The output always labels this clearly, so no confusion.\r\n\r\n**Q: It only shows code, not the number. How do I get the actual result?**\r\nA: Just say **\"please compute directly\"** in the chat — the assistant will really run the compute and give you the number. (On the coze engine this natural-language trigger fires the compute, **no `--yes` needed**; the legacy `--yes` flag applies only to the optional local-R dev backend.) This is the default safe design: see the request envelope first, compute once you're sure.\r\n\r\n**Q: I want the reproducible R code for submission or audit — how do I ask?**\r\nA: Say **\"give me the full R code\"**. The code is also shown in safe preview by default, so you can copy, modify, and re-run it yourself.\r\n\r\n**Q: On a Chinese system, is the output in Chinese?**\r\nA: Yes. By default the output language follows your OS language setting — Chinese on a Chinese-OS, English otherwise. You can force-switch anytime via a prompt (e.g. \"用中文回复\" / \"switch to English\").\r\n\r\n**Q: What if my data must stay confidential?**\r\nA: Use the same design framework but **replace the raw data** (e.g. run through the flow with placeholder values), ask the skill to output the full R code, then run that code yourself locally with your real data — the skill only ever sends design parameters and never touches your raw data.\r\n\r\n**Q: What if I found an error in the result — how do I report it?**\r\nA: This skill follows its built-in bug-report workflow. If you suspect the result is wrong (or the engine errored), just say **\"report a bug\" / \"上报问题\" / \"提交错误报告\"**. The skill also **proactively asks** whether to report when it detects a likely defect (e.g. the engine errors or retries still fail) — at most **once per session**, and you can always decline. Either way, the assistant will:\r\n1. **Propose a sanitized report** (11-field whitelist: skill / skill_version / test / error_type / error_code / engine_status / description / locale / query_origin / session_hash / attempts — **no raw input values or personal data**, except the `description` field where you decide what to disclose, e.g. the algorithm/function used and the error message);\r\n2. **Show the full report text for your review** — you can add a problem description or correct anything before confirming;\r\n3. **Send after your explicit confirmation** — to the unified endpoint `https://ct-bugreport.coze.site/run` (if this session called coze) or saved locally + emailed to the author (if purely local, data never leaves your machine);\r\n4. **Receive an acknowledgment** — including whether a previously submitted report from your source has already been fixed (with the fix note) or is still pending.\r\n\r\nYou stay in full control: the report is shown to you **before** anything is sent, and nothing is transmitted without your explicit \"send\" confirmation.\r\n\r\n---\r\n\r\n## 4. Safety & Disclaimer\r\n\r\n- **What is Safe Preview / coze compute:** The published skill **never runs R or a shell on your machine.** By default it calls the remote **coze** compute service (endpoint: `https://ct-samplesize.coze.site/run`) with only your trial-design parameters (never patient data). To inspect first, say **\"preview only / --dry-run\"** — it prints the exact request envelope and sends nothing. Say **\"please compute\"** to send and get the numbers + optional figures — on the coze stateless engine this natural-language trigger fires the compute, **no `--yes` needed** (the legacy `--yes` flag applies only to the optional local-R dev backend, not the published skill). Say **\"show code / --show-code\"** to see the coze request JSON (and the R source on request).\r\n- **What leaves the machine (metadata disclosure):** each coze request carries (1) your trial-design parameters (test type, effect size, α, power, n …), (2) `locale` derived from your OS language (for bilingual output), and (3) a **hostname hash** `query_origin` (SHA-256 of your computer's hostname — not the hostname itself; used by the author only for server attribution / abuse rate-limiting), and (4) your **skill version** `skill_version` (read from the local SKILL.md; used to attribute usage and failures per released version). No patient data, file content, or personally identifiable information is sent.\r\n- **Bug reports (optional, opt-in only):** if a likely skill defect is detected (e.g. engine error after retry), the assistant may ask whether to send a **sanitized** bug report to the author via the unified report endpoint (`https://ct-bugreport.coze.site/run`). It contains skill name/version/error type plus a **problem description you review and approve** — you may include the algorithm/function used, values and study design if needed; only identifiable person/institution/subject info is avoided. Nothing is sent without your confirmation; you can always decline, and in fully local sessions the report is saved as a file with the author's email instead.\r\n- **coze-only (v5):** the published skill has **no local compute fallback** — if the cloud compute service (`https://ct-samplesize.coze.site/run`) is unreachable, the skill reports the configuration error and guides you to set `CTSS_COZE_ENDPOINT` (or `CTSS_COZE_MOCK=1` for a local demo). All 49 test types run server-side via coze.\r\n- Outputs are for reference only; validate before regulatory submissions.\r\n\r\n---\r\n\r\n## 5. Advanced Reference (moved to a separate file)\r\n\r\nCLI examples, bidirectional solving, curve mode, core formulas, system requirements, common errors, file structure, and references for developers have been moved to **[ADVANCED.md](docs/ADVANCED.md)**. Ordinary users don't need it; see Sections 1-4 for daily use.\r\n\r\n---\r\n\r\n**Version**: v5.8.0 | **License**: MIT | **Authors**: medstatstar, phoe-zip\r\n\r\nFor feature requests, bug reports, or other feedback, please contact the author directly at medstatstar@gmail.com (Wintone Zhang / 张文彤).\r\n\r\n---\r\n\r\n## Confidentiality Notice\r\n\r\n> The CT series consists of 20+ specialized domain skills, organized into **two tiers — A, B** — by \"whether the input contains confidential information\" (network / egress / publish are independent orthogonal attributes), providing full coverage of the entire new-drug clinical trial (Clinical Trial) lifecycle.\r\n>\r\n> - **Tier A (non-confidential input)**: run fully locally using only ordinary data; Tier A may need external public retrieval but involves no confidential information. These skills are published openly on GitHub.\r\n> - **Tier B (confidential input)**: accept strictly confidential clinical-trial data / protocols / CRFs from pharma sponsors (e.g., ct-analysis, ct-sdtm, ct-protocol, ct-eligibility); Tier B is processed locally and never leaves the boundary (egress=none), or additionally requires policy approval (egress=approval-req, e.g. ct-eligibility). Tier B packages contain zero confidential data but are NOT publicly published (stays fully local) — confidential input never ships with the package or leaves the machine. For custom / on-prem deployment, contact the author.\r\n>\r\n> 📧 Contact: medstatstar@gmail.com (Wintone Zhang / 张文彤)\n\nFile v5.8.0:_meta.json\n\n{\n  \"ownerId\": \"kn7amqq1jv28skb63wavr6shah89jsm5\",\n  \"slug\": \"ct-samplesize\",\n  \"version\": \"5.8.0\",\n  \"publishedAt\": 1791547853622\n}\n\nFile v5.8.0:references/adaptive_simulator.md\n\n# Adaptive-Trial Monte-Carlo Simulator\r\n\r\nModule: `--test adaptive_simulate` in the main CLI. **In the published skill, the\r\nauthoritative engine is an inlined pure base-R function library** `ADAPTIVE_SIM_R`,\r\nmaintained in `adapters/coze/ct_r_lib/local_r_backend.py` (no extra R packages), running **server-side\r\non coze**. The CLI shows the coze request envelope in SAFE PREVIEW and computes via\r\ncoze (no local R/shell). **Dev / offline:** the equivalent local-R path writes the\r\ninlined engine to a temp `.R` file, `source()`s it and calls `run_adaptive_sim()`\r\n(SAFE PREVIEW, `--yes` to run). A legacy pure-Python module\r\n`adapters/coze/ct_r_lib/legacy/adaptive_simulator.py` is retained for offline dev/testing.\r\nPorted from the ClawHub skill `adaptive-trial-simulator` (aipoch-ai) and\r\nre-implemented to fit ct-samplesize.\r\n\r\n> **No standalone `.R` file is shipped in the published skill.** The R engine lives\r\n> inline in `adapters/coze/ct_r_lib/local_r_backend.py` as `ADAPTIVE_SIM_R` (excluded from the publish\r\n> package; synced to coze). To drive the engine from R yourself, run the CLI with\r\n> `--show-code` (or `-y`) and copy the printed R code into R.\r\n\r\n## Run the R engine via CLI\r\n\r\nThis is the normal path (no manual `source()` needed):\r\n\r\n```bash\r\n# default = SAFE PREVIEW (shows the generated R code that sources the inlined engine)\r\npython scripts/samplesize_power.py --test adaptive_simulate --sim_design group_sequential   --effect_size 0.3 --sim_n 200 --interim_looks 3 --spending_function obrien_fleming   --alpha 0.025 --n_simulations 20000 --sim_seed 42\r\n\r\n# add -y / --yes to execute and compute power / type I error\r\npython scripts/samplesize_power.py --test adaptive_simulate --sim_design group_sequential   --effect_size 0.3 --sim_n 200 --interim_looks 3 --spending_function obrien_fleming   --alpha 0.025 --n_simulations 20000 --sim_seed 42 -y\r\n```\r\n\r\n## Drive the engine directly from R\r\n\r\nThere is no standalone `.R` file to `source()`. To run the engine from R,\r\nreplicate what the CLI does: run `python scripts/samplesize_power.py --test\r\nadaptive_simulate ... --show-code`, copy the printed R code (it contains the full\r\n`ADAPTIVE_SIM_R` definition plus the `run_adaptive_sim(...)` call) into R, and run\r\nit. The pasted code is self-contained — base R only, no extra packages.\r\n\r\n## When to use\r\n\r\nUse this **simulation** engine when you want to *validate* an adaptive or\r\ngroup-sequential design by Monte-Carlo (empirical power, empirical type I error,\r\nexpected sample size, early-stop probabilities) rather than solve a closed-form\r\nsample size. For **analytic** group-sequential / adaptive sample size (rpact /\r\ngsDesign), use `--test group_sequential` or `--test adaptive` instead — they are\r\ncomplementary.\r\n\r\n> **coze is the primary compute path** in the published skill: the CLI shows the\r\n> coze request envelope (SAFE PREVIEW) and computes via coze (server-side R, base R\r\n> only, no extra packages). The optional local-R dev backend (`adapters/coze/ct_r_lib/`) behaves\r\n> like v3.x — R code is generated and shown, re-run with `--yes` to execute locally.\r\n> If neither coze nor a local R install is available, the legacy pure-Python engine\r\n> (`adapters/coze/ct_r_lib/legacy/adaptive_simulator.py`) still gives a result offline.\r\n\r\n## Capabilities (6)\r\n\r\n|#|Capability|How|\r\n|---|---|---|\r\n|1|Design Simulation|Monte-Carlo of the chosen design under H1 & H0|\r\n|2|Sample-Size Re-estimation|promising-zone + Cui-Hung-Wang weighted statistic|\r\n|3|Early Stopping|efficacy + non-binding futility boundaries|\r\n|4|Type I Error Control|alpha-spending calibration, verified under H0|\r\n|5|Multi-Arm|drop-the-loser interim selection (Dunnett/Bonferroni)|\r\n|6|Power Optimization|grid search for min per-arm N reaching target power|\r\n\r\n## Designs & spending\r\n\r\n- `--sim_design`: `group_sequential` | `adaptive_reestimate` | `drop_the_loser`\r\n- `--spending_function`: `obrien_fleming` (conservative early) | `pocock`\r\n  (aggressive early) | `power_family` (shape via `--rho`, e.g. 3)\r\n\r\nBoundaries are computed by an exact Armitage-McPherson-Rowe recursion on the\r\nBrownian (B-value) scale, reproducing gsDesign-style OBF/Pocock boundaries.\r\n\r\n## Key flags\r\n\r\n|Flag|Meaning|Default|\r\n|---|---|---|\r\n|`--sim_design`|design type|group_sequential|\r\n|`--effect_size`|Cohen's d (single-arm designs)|0.3|\r\n|`--effect_sizes`|per-arm d list for drop_the_loser, e.g. `0.2,0.35,0.5`|—|\r\n|`--sim_n`|per-arm sample size|100|\r\n|`--interim_looks`|looks incl. final|2|\r\n|`--spending_function`|alpha spending|obrien_fleming|\r\n|`--rho`|power_family shape|3.0|\r\n|`--futility` / `--beta`|add non-binding futility|off / 0.2|\r\n|`--reestimate_method`|SSR method|promising_zone|\r\n|`--interim_fraction` `--target_cp` `--max_inflation`|SSR controls|0.5 / 0.9 / 2.0|\r\n|`--n_arms` `--selection_fraction` `--correction`|multi-arm controls|3 / 0.5 / dunnett|\r\n|`--optimize` `--n_min` `--n_max` `--power`|power search|off / 10 / 1000 / 0.9|\r\n|`--n_simulations`|MC replications|10000|\r\n|`--alpha`|one-sided alpha (from common flag)|0.05|\r\n|`--visualize` `--sim_output` `--sim_seed`|PNG / JSON / seed|off / — / —|\r\n\r\n> Note: `--alpha` is the shared common flag (default 0.05). For a one-sided\r\n> 0.025 design pass `--alpha 0.025`.\r\n\r\n## Examples\r\n\r\n```bash\r\n# Default = SAFE PREVIEW (shows the generated R code). Append -y / --yes to\r\n# execute the R code and compute the result. If R is absent, the Python\r\n# fallback runs automatically (also without --yes).\r\n\r\n# 1) Group-sequential, 3 looks, OBF spending, one-sided 0.025  (preview)\r\npython samplesize_power.py --test adaptive_simulate --sim_design group_sequential \\\r\n  --effect_size 0.3 --sim_n 200 --interim_looks 3 --spending_function obrien_fleming \\\r\n  --alpha 0.025 --n_simulations 20000 --sim_seed 42\r\n\r\n# 1b) same, but execute (-y) -> runs the R code and prints power / type I error\r\npython samplesize_power.py --test adaptive_simulate --sim_design group_sequential \\\r\n  --effect_size 0.3 --sim_n 200 --interim_looks 3 --spending_function obrien_fleming \\\r\n  --alpha 0.025 --n_simulations 20000 --sim_seed 42 -y\r\n\r\n# 2) With non-binding futility (Pocock spending)\r\npython samplesize_power.py --test adaptive_simulate --sim_design group_sequential \\\r\n  --effect_size 0.3 --sim_n 200 --interim_looks 3 --spending_function pocock \\\r\n  --futility --beta 0.2 --alpha 0.025 -y\r\n\r\n# 3) Sample-size re-estimation (promising zone, CHW statistic)\r\npython samplesize_power.py --test adaptive_simulate --sim_design adaptive_reestimate \\\r\n  --effect_size 0.3 --sim_n 200 --interim_fraction 0.5 --target_cp 0.9 \\\r\n  --max_inflation 2.0 --alpha 0.025 -y\r\n\r\n# 4) Multi-arm drop-the-loser (3 arms) with Dunnett-style adjustment\r\npython samplesize_power.py --test adaptive_simulate --sim_design drop_the_loser \\\r\n  --effect_sizes \"0.2,0.35,0.5\" --sim_n 150 --selection_fraction 0.5 \\\r\n  --correction dunnett --alpha 0.025 -y\r\n\r\n# 5) Power optimization: min per-arm N reaching 90% power, + PNG\r\npython samplesize_power.py --test adaptive_simulate --optimize \\\r\n  --effect_size 0.3 --power 0.9 --interim_looks 2 --alpha 0.025 \\\r\n  --n_min 150 --n_max 400 --visualize -y\r\n\r\n# Standalone Python fallback (only needed when R is unavailable):\r\npython adaptive_simulator.py --design group_sequential --effect-size 0.3 \\\r\n  --sample-size 200 --interim-looks 3 --spending-function obrien_fleming --alpha 0.025\r\n```\r\n\r\n## Output\r\n\r\n**R engine (primary):** a human-readable report (power, type I error, expected /\r\nmax sample size, early-stop rates, Z boundaries, etc.) plus an optional JSON file\r\nwhen `--sim_output <path>` is given.\r\n\r\n**Python fallback (no R):** the same quantities as a JSON block with (design-dependent)\r\n`power`, `type_i_error`, `expected_sample_size` (total & per-arm), `max_sample_size`,\r\n`early_stop_rate {efficacy, futility}` (GS), `prob_sample_size_increase` (SSR),\r\n`power_correct_selection` / `prob_correct_selection` (multi-arm), and a `design_config`\r\nechoing all inputs plus the computed Z boundaries.\r\n\r\n## Validation\r\n\r\nAt α=0.025 the empirical type I error is calibrated to ≈0.025 across all\r\ndesigns (checked with 20k-40k replications): GS 3-look OBF → power 0.846 / T1E\r\n0.0251; SSR promising-zone → power 0.890 / T1E 0.0251 / 28% inflation prob;\r\ndrop-the-loser 3-arm → power_any 0.959 / correct-selection 0.693 / T1E 0.0235.\r\n\r\n## Statistical notes\r\n\r\n- Effect size is Cohen's d; final non-centrality is `d*sqrt(n/2)` per two-arm Z.\r\n- SSR uses the Cui-Hung-Wang (1999) weighted statistic `Zw = w1*Z1 + w2*Z2`\r\n  with pre-planned weights, preserving type I under data-dependent re-estimation.\r\n- Futility is non-binding beta-spending under H1 (efficacy boundaries computed\r\n  independently).\n\nFile v5.8.0:references/backend_optimization_2026-09-11.md\n\n# 后端优化建议（基于 2026-09-11 后端日志分析）\r\n\r\n> 来源：`CTDB_searchlog (3).xlsx`（26 条有效请求 / 199 行，11 分钟窗口，单会话，\r\n> skill_version 5.7.26，全部 `proportion_two`，status 全 ok）。\r\n> 本文档为**服务端（coze 部署侧）**改进项，客户端 v5.7.27 已落地守卫（见 CHANGELOG）；\r\n> 服务端改动需按既有节奏人工打包上传 Coze，客户端无依赖、可先发布。\r\n\r\n## 日志核心发现（服务端视角）\r\n\r\n| # | 发现 | 量化 | 影响 |\r\n|:--|:---|:---|:---|\r\n| 1 | 「单点+曲线」成对串行 | 13 单点 : 13 曲线（1:1） | ~50% 请求、~40s 计算可省（客户端 v5.7.27 已强化约束 + 守卫） |\r\n| 2 | 参数包过肥 | 135 参数/条（2.8KB），仅 6 个被消费 | 飞书日志全参数扫描假象；缓存签名噪声化 |\r\n| 3 | 同网格曲线重复计算 | `0.6:0.05:0.95` 8 点网格重复 5 次（38% 曲线请求） | TTL 缓存因参数微调脱靶 |\r\n| 4 | 日志空白行 | 173/199 行（87%）六字段全空 | 日志分析被脏数据污染 |\r\n\r\n## 服务端改进项\r\n\r\n### A. 同网格近似参数模糊缓存（命中 38% 曲线请求）\r\n\r\n现状：`state.py` / samplesize 节点对 `(test, params, mode, locale)` 全量归一化后做 10 分钟 TTL\r\n幂等缓存，`params` 中任一键变化（哪怕仅 `dropout_rate` 0→0.1）即脱靶。\r\n\r\n建议（按侵入性从低到高，三选一）：\r\n\r\n1. **签名前先「归一化裁剪」**：缓存签名计算前，把 `params` 按该 test 的 contract 白名单\r\n   （`required` ∪ 通用键 ∪ curve_*）裁剪——客户端 v5.7.27 守卫已在出站侧做了同样的裁剪，\r\n   两端对齐后，即使老版本客户端发来过肥信封，服务端签名也只含有效键。改动点：\r\n   签名计算函数处加一层 per-test 白名单过滤（白名单可内嵌或复用 `_contract_index.json` 的镜像）。\r\n2. **网格级缓存**：对 `curve_*_seq` 请求，签名只取 `(test, mode, 网格串, 网格消费参数集)`\r\n   （如 proportion_two 的曲线仅消费 p1/p2/alpha/side/ratio），其余键不进签名；命中后直接\r\n   复用 R 结果。适合网格重复率高的场景（本日志 38%）。\r\n3. **批量多场景接口**：扩展 batch 协议支持「同网格 + 多组参数」一次提交（batch 内逐项\r\n   独立缓存签名），配合客户端 `build_batch` 已有能力，把 5 次同网格请求压成 1 次。\r\n\r\n推荐 ①（改动最小、与客户端守卫天然对齐），②③ 视上线后日志再评估。\r\n\r\n### B. 飞书日志空白行修复（87% 脏数据）\r\n\r\n现象：199 行中 173 行 `ID/inittime/query_origin/skillname/querystr/resultstr` 六字段全空\r\n（连 ID 都没有），非正常预分配形态。\r\n\r\n排查方向：\r\n\r\n1. **写入侧**：`src/graphs/nodes/feishu_write_node.py` / `feishu_save_node.py`——检查是否存在\r\n   异常分支「先建行、后填字段」，异常时行已建但字段未写（本日志窗口 status 全 ok，\r\n   更可能是预分配/重试路径泄漏）；\r\n2. **导出侧**：若飞书多维表格模板预留下了大量空行，导出脚本未过滤 `query_origin == null`\r\n   的行——最低成本修复是在导出端过滤空行，同时排查写入端是否确有泄漏路径；\r\n3. **建议加写入侧断言**：写行前校验 `querystr` 非空，空则跳过并计数上报（避免静默膨胀）。\r\n\r\n### C.（可选）skill_version 缺失兜底\r\n\r\n客户端 `_skill_version()` 正则在 v5.7.26 及以前**全部损坏**（从未从 SKILL.md 读到过版本），\r\n历史日志中的 `skill_version` 全部来自 fallback 常量，**升版归因可能静默漂移**。\r\n服务端无需改动（客户端 v5.7.27 已修），但做日志归因分析时请注意 5.7.26 及以前的\r\n版本号可信度有限。\r\n\r\n## 部署顺序\r\n\r\n1. 客户端 v5.7.27 先发（守卫 + 正则修复，全离线验证通过，无服务端依赖）；\r\n2. 服务端 A① / B 随下一次 coze 打包部署一并上线；\r\n3. 上线后取一段新日志复测：请求参数键数（期望 ~10-20）、缓存命中率、空白行占比。\n\nFile v5.8.0:references/batch_calls.md\n\n# Batch-call governance (v5.7, must-read)\r\n\r\n> Feishu backend evidence: a single analysis was split into **cell-by-cell serial** calls (54 calls over 4 min 15 s), about half being **\"single-point + curve\" paired redundancy**, plus **byte-for-byte repeated full re-runs**. v5.7 server now supports `batch` mode + request-level idempotent caching (auto-dedup), but **the orchestration side must converge** — otherwise redundant calls persist. The following three are mandatory constraints:\r\n\r\n1. **Curve response already carries the single point — forbid \"single-point first, then curve\":** a response with `curve_*_seq` already contains the requested single point in its x/y series (e.g. `curve_power_seq` returns the n series with corresponding power). **When a curve is needed, fire only ONE call with `curve_*_seq`; do NOT first fire a single-point n call then a curve call** — this alone cuts ~50% of calls.\r\n2. **Grid / sensitivity scans go through batch, submitted in one shot:** when traversing a p1×p2×power or nobs×d grid, use `adapters/coze_client.py`'s `build_batch([(test,args,ctx), ...])` to assemble `{\"batch\":[{test,mode,params}, ...]}` and POST it to `/run` **once**. The server computes each item and merges the Feishu log into a single line. Never hit the endpoint cell-by-cell serially.\r\n3. **Send only fields that apply to this test (trim the envelope):** always use `build_params` (whitelist drawn from the `required` fields in `tests/coze_cases/_contract_index.json`); **do NOT** dump the whole family's default params (varcorr/sigma/nsim/design/…) into params — that bloats the Feishu log and makes real requests indistinguishable from test samples. `build_params` already sends only required + alpha + key mode params + curve params by default.\r\n\r\n> Cache semantics: the server keeps a **10-minute TTL cache** on the normalized `(test, params, mode, locale)` signature (`CTSS_CACHE_TTL` tunable). Repeated planning/rendering of the same grid point by the upper-layer Agent is auto-deduped; a cache hit reuses the R result directly (only the S3 link is re-signed; figures stay downloadable).\r\n\r\n> **Backend-log evidence (2026-09-11, v5.7.27 hardening):** 26 requests / 11 min / single session showed all three violations co-occurring — ① 13 single-point + 13 curve **paired serial calls** (curve already contains the single point → ~50% of calls wasted); ② every request carried **~135 params (2.8 KB)** while only 6 were consumed (orchestrator bypassed `build_params` and hand-assembled the full-family argparse dump — a red-line violation); ③ the same 8-point grid `0.6:0.05:0.95` recomputed 5× (38% of curve calls) because noise keys defeat the TTL-cache signature. The client now enforces an **outbound envelope guard** (`_trim_bloated_params`): params far exceeding the test's contract whitelist are trimmed to `required ∪` generic/curve keys with a stderr warning — but the guard is a safety net, NOT permission to bypass `build_params`. Orchestration-side discipline (constraints 1–3 above) remains mandatory.\r\n\r\n## Local batch calls (CLI `--batch-file`)\r\n\r\nWrite the whole grid / sensitivity scan into a JSON-array file and submit once — the local side renders each item and merges the summary (corresponds to mandatory constraint 2). Each entry lists only **the differing fields**; the rest inherit CLI defaults; `ctx.solve_for_power=true` reverses that item to solve power. CLI examples & output format → `references/cli_examples.md`.\n\nFile v5.8.0:references/bug_report_endpoint.md\n\n# Bug Report Endpoint Protocol (ct-samplesize)\r\n\r\n> Detailed protocol for `adapters/bug_report.py`. The SKILL.md `## Bug Reporting` section keeps only the agent-facing behavior rules; implementation specifics live here.\r\n\r\n## Trigger\r\n\r\nTwo paths:\r\n\r\n- **(A) Explicit user request** — \"report a bug\" / \"反馈问题\" / \"提交错误报告\": go straight to two-stage confirmation, no strong signal needed, **unlimited per session**.\r\n- **(B) Strong signal** — CLI non-zero exit / engine error / user questions correctness — **and** the same operation was retried ≥1 → **at most 1 unsolicited proposal per session**.\r\n- Weak signal (just repeated tuning) never triggers.\r\n- Explicit user request takes priority over the once-per-session cap.\r\n\r\n## Two-stage confirmation (2026-08-21, simplified from three-stage)\r\n\r\n1. **Propose-with-preview** — give the bilingual `confirm_prompt` **together with** the full report (`render_report_text`). State \"sanitized, no input data\" and invite a problem description. If the user adds a `description`, re-render and re-show before consent.\r\n2. **On explicit consent** → `send_to_endpoint` (auto `action=report`, endpoint `https://ct-bugreport.coze.site/run`, `token` = embedded public credential).\r\n3. If the user declines, **never re-propose this session**.\r\n\r\n## Sanitization (hard rule)\r\n\r\n- Report contains **only** the 11-key whitelist: `skill` / `version` / `test` / `error_type` / `error_code` / `engine_status` / `description` / `locale` / `query_origin` / `session_hash` / `attempts` — never raw data files or subject records.\r\n- `description` is the single free-text field for debugging, **user-reviewed disclosure**: write symptom / reproduction / expected vs actual / **algorithm or function used** (e.g. Schoenfeld formula) / error message. Values and study design (HR, power, allocation ratio) are OK if needed to reproduce.\r\n- **Hard boundary**: no identifiable person / institution / subject info.\r\n- The user reviews `description` in the stage-① preview before consent. Empty `description` omits the key (old-endpoint compatible).\r\n- If the session had **no** coze call, use `save_local_report()` (local md + author email, data never leaves the machine).\r\n\r\n## Post-send history receipt (2026-08-22)\r\n\r\nAfter a successful send, the endpoint returns `history` (last submission for the same `query_origin`, or `\"\"`). Compose the reply from `confirm_thanks(locale)` + `build_followup(history, locale)` — bilingual, auto-switched by `locale`:\r\n\r\n- empty `history` → end;\r\n- `history.resultstr == \"done\"` → also show the fix note from `history.memo`;\r\n- otherwise show \"not yet fixed\".\r\n\r\nAll user-facing strings are bilingual via `_MSGS` and `_current_locale()` auto-detection.\r\n\r\n## Client-only boundary\r\n\r\nThis adapter sends `report` only. The governance actions (get / update / download / delete — pull pending, mark done, download all, clean up) are reserved for the `ct-update` skill (author side); **never call them from here**.\n\nFile v5.8.0:references/cli_examples.md\n\n# Command-Line Examples\r\n\r\n> This file collects all common CLI examples for `scripts/samplesize_power.py`, referenced by `SKILL.md`.\r\n> By default the skill runs in SAFE PREVIEW: the exact coze request envelope is shown but NOT sent/computed. On the coze engine the natural-language trigger (\"please compute directly\" / 请直接计算) fires the compute — **no `--yes` needed**; the legacy `--yes`/`-y` flag applies only to the optional local-R dev backend (`adapters/coze/ct_r_lib/`). `--show-code` displays the coze request JSON (no send); `--dry-run` is the default preview mode (envelope shown, not sent).\r\n> Sequences support two formats: comma list `\"20,40,200\"` or auto-generated `\"20:20:200\"` (start:step:stop).\r\n\r\n---\r\n\r\n## Quick Menu\r\n\r\n| Test Type | Clinical Scenario | R Package(s) |\r\n|:---|:---|:---|\r\n\r\n### ① Continuous\r\n| `ttest_ind` | Two-means comparison (parallel) | `pwr`, `TrialSize` |\r\n| `ttest_paired` | Paired t-test (2×2 crossover) | `pwr`, `TrialSize` |\r\n| `ttest_one` | One-sample vs known mean | `pwr` |\r\n| `anova` | Multi-group comparison (k groups) | `pwr`, `TrialSize` |\r\n| `equivalence` | Equivalence test (means) | `TrialSize` |\r\n| `mixed_model` | Repeated measures longitudinal | `simr` |\r\n\r\n### ② Binary Proportions\r\n| `proportion_one` | Single-group rate | `pwr` |\r\n| `proportion_two` | Two-group rate (chi-square) | `pwr`, `TrialSize` |\r\n| `proportion_paired` | Paired rate (McNemar) | `TrialSize` |\r\n| `odds_ratio` | Odds ratio | `pwr`, `TrialSize` |\r\n| `risk_ratio` | Risk ratio (RR) | `pwr`, `TrialSize` |\r\n| `non_inferiority` | Non-inferiority (rate) | `TrialSize` |\r\n| `superiority_margin` | Superiority (margin) | `TrialSize` |\r\n| `be_tost` | Bioequivalence (TOST) | `PowerTOST` |\r\n| `vaccine_efficacy` | Vaccine efficacy | Halloran formula |\r\n| `gsd_proportion` | Group-sequential two proportions | `rpact` |\r\n\r\n### ③ Count Rates\r\n| `poisson` | Poisson rate (recurrent events) | Wald test |\r\n| `recurrent_events` | Recurrent events (Andersen-Gill) | Poisson (base R) |\r\n| `gsd_poisson` | Group-sequential two Poisson rates | `rpact` |\r\n\r\n### ④ Survival Time-to-event\r\n| `survival` | Survival (simplified) | Schoenfeld formula |\r\n| `survival_exact` | Survival (exact) | `rpact` |\r\n| `ni_survival` | Non-inferiority survival | `powerSurvEpi` |\r\n| `survival_equivalence` | Survival equivalence (TOST log-HR) | closed-form (base R) |\r\n| `survival_superiority` | Survival superiority w/ margin | closed-form (base R) |\r\n| `cox_covariate` | Cox regression w/ covariate (R²) | Vittinghoff (base R) |\r\n| `survival_one_sample` | One-sample exponential survival | closed-form (base R) |\r\n| `competing_risks` | Competing risks (cum. incidence) | 2-sample proportion (base R) |\r\n| `survival_historical` | Historical-control logrank | closed-form (base R) |\r\n| `gsd_survival` | Group-sequential logrank (two survival curves) | `rpact` |\r\n| `gsd_hazard` | Group-sequential hazard ratio (HR) | `rpact` |\r\n| `gsd_survival_sim` | Group-sequential logrank — Monte-Carlo SIMULATION | `rpact` |\r\n| `gsd_hazard_sim` | Group-sequential hazard ratio — Monte-Carlo SIMULATION | `rpact` |\r\n\r\n### ⑤ Diagnostic Method comparison\r\n| `roc` | ROC curve diagnostic trial | `pROC` |\r\n| `bland_altman` | Bland-Altman method comparison | Lu et al. formula |\r\n\r\n### ⑥ Special Advanced designs\r\n| `group_sequential` | Group sequential interim analysis (rpact **exact**, two-sample means) | `rpact` |\r\n| `adaptive` | Adaptive design | `rpact` |\r\n| `adaptive_simulate` | Adaptive design — Monte-Carlo SIMULATION | `rpact` |\r\n| `bayesian` | Bayesian design | `BayesCTDesign` |\r\n| `dose_escalation` | Dose escalation (Phase I) | `escalation` |\r\n| `mams` | Multi-arm multi-stage (MAMS) | `rpact` |\r\n| `dunnett` | Dunnett multiple comparison | Custom formula |\r\n| `win_ratio` | Win-Ratio composite | `BuyseTest` simulation |\r\n| `must_win` | Must-Win co-primary | Correlation method |\r\n| `historical_controls` | Historical control borrowing | `RBesT` MAP prior |\r\n| `conditional_power` | Conditional power SSR | `rpact` |\r\n| `assurance` | Bayesian assurance | Monte Carlo |\r\n| `multiple_endpoints` | Multi-endpoint composite | Correlation method |\r\n| `mediation` | Mediation effect | `powerMediation` |\r\n| `cluster` | Cluster randomized | DEFF formula |\r\n\r\n---\r\n\r\n## Common Flags\r\n\r\n| Flag | Meaning |\r\n|:---|:---|\r\n| `--test <type>` | Test type (required) |\r\n| `--power 0.8` | Target power (forward: solve n given power) |\r\n| `--nobs N` | Given sample size (reverse: solve power; mutually exclusive with `--power`, `--nobs` wins) |\r\n| `--n_seq \"20:20:200\"` | Sample-size sequence → Power curve (x=n, y=power) |\r\n| `--power_seq \"0.6:0.05:0.95\"` | Power sequence → sample-size curve (x=power, y=n) |\r\n| `--plot_effects \"0.3,0.5,0.8\"` | Overlay multiple effect-size curves (sensitivity; some types) |\r\n| `--effect_seq \"0.1:0.05:0.9\"` | **Effect-size as continuous X axis** → effect-axis curve; y = Power with `--nobs`/`--n_seq`, y = sample size (n) with `--power_seq`. Supported by the 9 curve tests (ttest×3 / anova / proportion×2 / survival / equivalence / be_tost). |\r\n| `--dist_plot` | **① H0/H1 distribution-overlap plot**: standardized-effect space, two normal densities, α/β regions shaded. Supported: `ttest_ind` `ttest_paired` `ttest_one` `proportion_two` `proportion_one` `survival`. |\r\n| `--power_time_seq \"1:0.5:4\"` | **③ Survival follow-up–power curve (survival only)**: x = study duration, y = power; needs `--event_rate` (per-unit hazard) + `--accrual_time` in the same time unit. Marks time-to-target-power. |\r\n| `--heatmap` | **④ Power heatmap**: needs `--n_seq` (sample size) × `--effect_seq` (effect size); fills power over the 2-D grid. Supported by the 9 curve tests. |\r\n| `--out path.png` | Curve PNG output path (default: system temp) |\r\n| `-y/--yes` | Explicitly execute R code and compute (legacy local-R dev backend only; coze engine needs no `--yes` — the natural-language trigger fires the compute) |\r\n| `--dry-run` | Show the exact coze request envelope only, nothing sent (safe preview, default) |\r\n\r\n---\r\n\r\n## Implementation Examples\r\n\r\n```bash\r\n# === Continuous ===\r\npython scripts/samplesize_power.py --test ttest_ind --effect 0.5 --power 0.8\r\npython scripts/samplesize_power.py --test ttest_paired --effect 0.5 --power 0.8\r\npython scripts/samplesize_power.py --test anova --effect 0.25 --k_groups 3 --power 0.8\r\npython scripts/samplesize_power.py --test equivalence --margin 2.0 --effect 3.0 --power 0.8\r\n\r\n# === Binary ===\r\n# proportion_* convention: --p1 = control/original, --p2 = experimental/new\r\npython scripts/samplesize_power.py --test proportion_two --p1 0.15 --p2 0.30 --power 0.8\r\npython scripts/samplesize_power.py --test proportion_two --p1 0.15 --p2 0.30 --power 0.8 --side one\r\npython scripts/samplesize_power.py --test proportion_one --p1 0.40 --p2 0.50 --power 0.8\r\npython scripts/samplesize_power.py --test proportion_paired --p1 0.15 --p2 0.30 --power 0.8\r\npython scripts/samplesize_power.py --test odds_ratio --p1 0.30 --p2 0.50 --power 0.8\r\npython scripts/samplesize_power.py --test risk_ratio --p1 0.30 --p2 0.50 --power 0.8\r\npython scripts/samplesize_power.py --test non_inferiority --margin 0.1 --p1 0.85 --p2 0.80 --power 0.8\r\npython scripts/samplesize_power.py --test superiority_margin --sup_margin 0.05 --p_control_sup 0.3 --delta_sup 0.15\r\n\r\n# === Count ===\r\npython scripts/samplesize_power.py --test poisson --lambda1 0.05 --lambda2 0.03 --t1 2 --t2 2 --power 0.8\r\n\r\n# === Survival ===\r\npython scripts/samplesize_power.py --test survival --hazard_ratio 0.75 --power 0.85\r\n\r\n# === Survival — PASS extensions (v3.5) ===\r\npython scripts/samplesize_power.py --test survival_equivalence --eq_margin_surv 1.25 --hr_expected 1.0 --accrual_time 12 --followup_time 12 --event_rate 0.7 --power 0.8\r\npython scripts/samplesize_power.py --test survival_superiority --sup_margin_surv 0.8 --sup_hr 0.67 --accrual_time 12 --followup_time 12 --event_rate 0.7 --power 0.8\r\npython scripts/samplesize_power.py --test cox_covariate --cox_hr 2.0 --cox_r2 0.3 --cox_prev 0.5 --cox_event_prop 0.3 --power 0.8\r\npython scripts/samplesize_power.py --test survival_one_sample --median0 12 --median1 18 --accrual_time 12 --followup_time 12 --power 0.8\r\npython scripts/samplesize_power.py --test competing_risks --ci_control 0.2 --ci_treatment 0.1 --power 0.8\r\npython scripts/samplesize_power.py --test recurrent_events --rate_control 1.0 --rate_ratio 0.6 --recur_followup 2 --power 0.8\r\npython scripts/samplesize_power.py --test survival_historical --hist_median 12 --new_median 18 --hist_n 100 --accrual_time 12 --followup_time 12 --power 0.8\r\n\r\n# === Special Designs ===\r\npython scripts/samplesize_power.py --test cluster --icc 0.05 --m 30 --n_indiv 64\r\npython scripts/samplesize_power.py --test group_sequential --n_interim 1 --effect_gs 0.4\r\n# === Group-sequential (PASS, rpact-backed) — v3.6 ===\r\npython scripts/samplesize_power.py --test gsd_proportion --n_interim 1 --p1 0.7 --p2 0.5 --power 0.8     # -> n~=75/arm\r\npython scripts/samplesize_power.py --test gsd_survival  --n_interim 1 --gs_median_control 12 --hazard_ratio 0.7 --accrual_time 12 --followup_time 12 --power 0.8   # -> n~=178/arm (198 events)\r\npython scripts/samplesize_power.py --test gsd_hazard    --n_interim 1 --gs_median_control 12 --hazard_ratio 0.7 --accrual_time 12 --followup_time 12 --power 0.8   # -> n~=178/arm\r\npython scripts/samplesize_power.py --test gsd_survival_sim --n_interim 2 --gs_median_control 12 --hazard_ratio 0.7 --accrual_time 12 --followup_time 12 --power 0.8 --n_simulations 2000 --sim_seed 1   # Monte-Carlo: empirical power ~0.78\r\npython scripts/samplesize_power.py --test gsd_hazard_sim    --n_interim 2 --gs_median_control 12 --hazard_ratio 0.7 --accrual_time 12 --followup_time 12 --nobs 180\r\npython scripts/samplesize_power.py --test gsd_poisson   --n_interim 1 --gs_rate1 0.6 --gs_rate2 1.0 --gs_poisson_time 2 --power 0.8   # -> n~=33/arm\r\n# Spending functions + futility (shared by 5 types)\r\npython scripts/samplesize_power.py --test group_sequential --n_interim 2 --effect_gs 0.4 --spending_func Pocock --futility --power 0.8\r\npython scripts/samplesize_power.py --test group_sequential --n_interim 1 --effect_gs 0.4 --spending_func WT --wt_delta 0.25 --power 0.8   # Wang-Tsiatis Delta=0.25; cannot combine with --futility\r\n# Reverse: given n -> power (consistent with forward n)\r\npython scripts/samplesize_power.py --test gsd_proportion --n_interim 1 --p1 0.7 --p2 0.5 --nobs 75        # -> power~=0.80\r\npython scripts/samplesize_power.py --test gsd_survival  --n_interim 1 --gs_median_control 12 --hazard_ratio 0.7 --accrual_time 12 --followup_time 12 --nobs 178   # -> power~=0.82\r\n```\r\n\r\n---\r\n\r\n## Reverse Examples\r\n\r\n```bash\r\n# Reverse: n=50 per group → achieved power for two-sample t-test\r\npython scripts/samplesize_power.py --test ttest_ind --effect 0.5 --nobs 50\r\n\r\n# Reverse: n=20 per sequence → achieved power for bioequivalence TOST\r\npython scripts/samplesize_power.py --test be_tost --nobs 20\r\n\r\n# BE with custom equivalence limits (theta0=1, CV=30%, limits 0.5~2, power 0.8) — 2026-08-20\r\npython scripts/samplesize_power.py --test be_tost --theta0 1 --cv 0.3 --theta1 0.5 --theta2 2 --power 0.8\r\n# Same via --margin (margin=2 → limits 1/2 ~ 2)\r\npython scripts/samplesize_power.py --test be_tost --theta0 1 --cv 0.3 --margin 2 --power 0.8\r\n\r\n# Reverse: n=100 per group → achieved power for MAMS design\r\npython scripts/samplesize_power.py --test mams --nobs 100\r\n\r\n# Reverse: the 7 new PASS-survival tests also accept --nobs (solve power)\r\npython scripts/samplesize_power.py --test survival_equivalence --eq_margin_surv 1.25 --hr_expected 1.0 --accrual_time 12 --followup_time 12 --event_rate 0.7 --nobs 350\r\n```\r\n\r\n**Covers all 49 test types.** Reverse-solve strategy:\r\n- **Native package reverse (priority):** `pwr.*` (`pwr.t.test(n=)` auto-reverses), `PowerTOST::power.TOST(n=)`, `rpact::getPowerMeans/getPowerSurvival(n=)` — exact.\r\n- **Analytic inverse:** self-written tests (ROC, Poisson, vaccine efficacy, multi-endpoint, Bayesian, Win Ratio, MAMS etc.) back-solve `z_b` via non-centrality, then `power = pnorm(z_b)`.\r\n- **Approx/precision:** `bland_altman` returns achievable CI half-width (precision, not power); `dose_escalation` is heuristic design (power N/A); `conditional_power`/`assurance` `--nobs` maps directly to planned/assurance sample size.\r\n\r\n*Note: `roc` uses `--auc1`/`--effect`; `mixed_model` uses `--effect_name`.*\r\n\r\n---\r\n\r\n## Curve Mode Examples\r\n\r\n```bash\r\n# Power curve: n = 20,40,...,200, overlaying 3 effect-size curves\r\npython scripts/samplesize_power.py --test ttest_ind --n_seq \"20:20:200\" --plot_effects \"0.3,0.5,0.8\" --out power_curve.png\r\n\r\n# Sample-size curve: power = 0.6,0.65,...,0.95\r\npython scripts/samplesize_power.py --test ttest_ind --power_seq \"0.6:0.05:0.95\" --out n_curve.png\r\n\r\n# Effect-axis curve (Power vs Cohen's d, fixed n=100): x = effect size, y = power\r\npython scripts/samplesize_power.py --test ttest_ind --effect_seq \"0.1:0.05:0.9\" --nobs 100 --out effect_power_curve.png\r\n\r\n# Effect-axis curve (required n vs Hazard ratio, fixed target power=0.8): x = HR, y = events\r\npython scripts/samplesize_power.py --test survival --effect_seq \"0.5:0.05:0.9\" --power_seq \"0.8\" --out effect_n_curve.png\r\n\r\n# ① Distribution-overlap plot (ttest_ind, d=0.5, n=100): shades α/β regions\r\npython scripts/samplesize_power.py --test ttest_ind --nobs 100 --effect 0.5 --dist_plot --out dist_overlap.png\r\n\r\n# ③ Survival follow-up–power curve: x = years, y = power; event_rate=0.1/yr, accrual=1yr\r\npython scripts/samplesize_power.py --test survival --nobs 200 --hazard_ratio 0.7 \\\r\n    --event_rate 0.1 --accrual_time 1 --power_time_seq \"1:0.5:4\" --out surv_power_time.png\r\n\r\n# ④ Power heatmap: n_seq (sample size) × effect_seq (Cohen's d), fill = power\r\npython scripts/samplesize_power.py --test ttest_ind --heatmap \\\r\n    --n_seq \"30:30:150\" --effect_seq \"0.2:0.2:1.0\" --out power_heatmap.png\r\n```\r\n\r\n**Curve mode supports 9 core test types:** ttest_ind, ttest_paired, ttest_one, anova, proportion_one, proportion_two, survival, equivalence, be_tost.\r\n\r\nCurve mode reuses the same validated formulas as single-point solving (pwr, PowerTOST, analytic inverse) — numerically identical.\r\n\r\nAll other test types (incl. odds_ratio, risk_ratio, roc, poisson, non_inferiority, superiority_margin, ni_survival, vaccine_efficacy, group_sequential, survival_exact, mams, dunnett, mixed_model, bayesian, win_ratio, …) support single-point solving only; a curve request returns a clear \"curve not supported\" notice at runtime.\r\n\r\n---\r\n\r\n## R Package Install\r\n\r\n> v5: R packages run **server-side on coze** — the published skill never installs R locally. The legacy CLI flags (`--install-all-packages` / `--run-install`) were **removed in v5.0.2**. The notes below apply only to the optional local-R dev backend (`adapters/coze/ct_r_lib/`, not shipped).\r\n\r\n- **Install on demand (dev backend):** when the skill prints `Warning: 'xxx' package not found.`, run `install.packages(\"xxx\")`.\r\n- **No R package needed:** `poisson`, `cluster`, `bland_altman`, `survival` (Schoenfeld only), `vaccine_efficacy`, `bayesian`, `dose_escalation` etc.\r\n\r\nFull R package list: `references/r_packages.md`.\n\nFile v5.8.0:references/data_format_guide.md\n\n# Data Format Guide\r\n\r\n> This guide takes the \"what data do you need to prepare\" angle and gives a friendly input framework for each of the 49 test types.\r\n> Each type includes: a **parameter table to fill in** + **a real example** + **data-source hints**.\r\n\r\n---\r\n\r\n## 📌 General Parameters (all types)\r\n\r\n| Param | Description | Default | Example |\r\n|:-----|:-----|:-----|:---------|\r\n| `α` (alpha) | Significance level, two-sided | 0.05 | 0.05 |\r\n| `Power` | Test power | 0.8 | 0.8 / 0.85 / 0.9 |\r\n| `--show-code` | Show the coze request JSON (no send) | SAFE PREVIEW by default: envelope shown, nothing sent | coze needs no `--yes` — natural-language trigger fires compute; `--yes` is legacy local-R dev only |\r\n\r\n---\r\n\r\n## Continuous\r\n\r\n### 1. `ttest_ind` — Two-sample t-test\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|:---------|\r\n| `--effect` | ✅ | Cohen's d (effect size) | (μ₁ - μ₂) / σ |\r\n| `--alpha` | | 0.05 | 0.05 |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test ttest_ind --effect 0.5 --power 0.8 -y\r\n```\r\n\r\n- Cohen's d = (Mean₁ - Mean₂) / SD_pooled\r\n- Cohen's d benchmarks: 0.2 = small, 0.5 = medium, 0.8 = large\r\n- d = standardized mean difference\r\n\r\n---\r\n\r\n### 2. `ttest_paired` — Paired t-test (2×2)\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--effect` | ✅ | Cohen's d = mean difference / SD | 0.4 |\r\n| `--alpha` | | 0.05 | 0.05 |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test ttest_paired --effect 0.4 --power 0.85 -y\r\n```\r\n\r\n- Paired design\r\n- versus independent two-sample\r\n\r\n---\r\n\r\n### 3. `anova` — One-way ANOVA\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--effect` | ✅ | Cohen's f | 0.25 |\r\n| `--k_groups` | | 2 | 3 |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test anova --effect 0.25 --k_groups 3 --power 0.8 -y\r\n```\r\n\r\nCohen's f benchmarks: 0.1 = small, 0.25 = medium, 0.4 = large\r\n\r\n---\r\n\r\n### 4. `equivalence` — Equivalence (TOST)\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--margin` | ✅ | δ (equivalence margin) | 2.0 |\r\n| `--effect` | ✅ | σ (SD) | 3.0 |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test equivalence --margin 2.0 --effect 3.0 --power 0.8 -y\r\n```\r\n\r\n---\r\n\r\n### 5. `mixed_model` — Mixed Model (R `simr`)\r\n\r\n| Parameter | Description |\r\n|:-----|:-----|\r\n| (β) | fixed effects vector |\r\n| VarCorr | random effect variance |\r\n| SD (σ) | residual standard deviation |\r\n| \"treatment_effect\" | named effect of interest |\r\n\r\n**CLI**\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test mixed_model --effect 0.5 --nsim 500 -y\r\n```\r\n\r\n---\r\n\r\n## Binary\r\n\r\n### 6. `proportion_one` — One-sample proportion\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--p1` | ✅ | proportion under H1 | 0.3 |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n---\r\n\r\n### 7. `proportion_two` — Two-sample proportion\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--p1` | ✅ | treatment proportion | 0.3 |\r\n| `--p2` | ✅ | control proportion | 0.15 |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test proportion_two --p1 0.3 --p2 0.15 --power 0.8 -y\r\n```\r\n\r\n---\r\n\r\n### 8. `non_inferiority` — Non-inferiority\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--p1` | ✅ | treatment proportion | 0.85 |\r\n| `--p2` | ✅ | control proportion | 0.80 |\r\n| `--margin` | ✅ | NI margin | 0.1 |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test non_inferiority --p1 0.85 --p2 0.80 --margin 0.1 --power 0.8 -y\r\n```\r\n\r\n---\r\n\r\n### 9. `superiority_margin` — Superiority by a margin\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--sup_margin` | ✅ | δ (margin) | 0.05 |\r\n| `--p_control_sup` | ✅ | control proportion | 0.3 |\r\n| `--delta_sup` | ✅ | target difference | 0.15 |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test superiority_margin --sup_margin 0.05 --p_control_sup 0.3 --delta_sup 0.15 -y\r\n```\r\n\r\n---\r\n\r\n### 10. `be_tost` — Bioequivalence (TOST)\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--theta0` | ✅ | T/R ratio, e.g. 0.95 | 0.95 |\r\n| `--cv` | ✅ | CV, e.g. 0.25 | 0.25 |\r\n| `--design` | | \"2x2\" | \"2x2\" |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test be_tost --theta0 0.95 --cv 0.25 --design \"2x2\" -y\r\n```\r\n\r\nSupported designs: \"2x2\", \"2x4\", \"3x3\", \"2x2x2\", \"2x2x3\", \"2x2x4\"\r\n\r\n---\r\n\r\n## Count\r\n\r\n### 11. `poisson` — Poisson rate comparison\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--lambda1` | ✅ | rate group 1 | 0.05 |\r\n| `--lambda2` | ✅ | rate group 2 | 0.03 |\r\n| `--t1` | | 1.0 | 2.0 |\r\n| `--t2` | | 1.0 | 2.0 |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test poisson --lambda1 0.05 --lambda2 0.03 --t1 2 --t2 2 -y\r\n```\r\n\r\n---\r\n\r\n### 12. `vaccine_efficacy` — Vaccine efficacy\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--ve_control` | ✅ | attack rate control (ARU) | 0.02 |\r\n| `--ve_treatment` | ✅ | attack rate vaccine (ARV) | 0.005 |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test vaccine_efficacy --ve_control 0.02 --ve_treatment 0.005 -y\r\n```\r\n\r\n---\r\n\r\n## Time-to-Event (Survival)\r\n\r\n### 13. `survival` — Survival (logrank)\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--hazard_ratio` | ✅ | hazard ratio (HR), e.g. 0.75 | 0.75 |\r\n| `--power` | | 0.8 | 0.85 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test survival --hazard_ratio 0.75 --power 0.85 -y\r\n```\r\n\r\n---\r\n\r\n### 14. `survival_exact` — Survival exact\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--hr_exact` | ✅ | HR, e.g. 0.75 | 0.75 |\r\n| `--accrual_exact` | ✅ | accrual time | 12 |\r\n| `--followup_exact` | ✅ | follow-up time | 12 |\r\n| `--event_rate_exact` | | 0.3 | 0.3 |\r\n| `--dropout_exact` | | 0.05 | 0.05 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test survival_exact --hr_exact 0.75 --accrual_exact 12 --followup_exact 12 -y\r\n```\r\n\r\n---\r\n\r\n### 15. `ni_survival` — Non-inferiority survival\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--ni_margin_surv` | ✅ | HR margin, e.g. 1.25 | 1.25 |\r\n| `--hr_expected` | | HR 1.0 | 1.0 |\r\n| `--accrual_time` | | 12 | 12 |\r\n| `--followup_time` | | 12 | 12 |\r\n| `--event_rate` | | 0.3 | 0.3 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test ni_survival --ni_margin_surv 1.25 --accrual_time 12 --followup_time 12 -y\r\n```\r\n\r\n---\r\n\r\n## Diagnostic\r\n\r\n### 16. `roc` — ROC curve\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--auc1` | ✅ | AUC under H1, e.g. 0.75 | 0.75 |\r\n| `--auc0` | | AUC under H0 = 0.5 | 0.5 |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test roc --auc0 0.5 --auc1 0.75 -y\r\n```\r\n\r\n---\r\n\r\n### 17. `bland_altman` — Bland-Altman\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--sd_diff` | ✅ | SD of differences | 5 |\r\n| `--w` | ✅ | half-width of LoA | 2.5 |\r\n| `--alpha` | | 0.05 | 0.05 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test bland_altman --sd_diff 5 --w 2.5 -y\r\n```\r\n\r\n---\r\n\r\n## Special Designs\r\n\r\n### 18. `cluster` — Cluster-randomized\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--icc` | ✅ | intraclass correlation (ICC), e.g. 0.05 | 0.05 |\r\n| `--m` | ✅ | cluster size, e.g. 30 | 30 |\r\n| `--n_indiv` | ✅ | individuals per cluster | 64 |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test cluster --icc 0.05 --m 30 --n_indiv 64 -y\r\n```\r\n\r\n---\r\n\r\n### 19. `multiple_endpoints` — Multiple endpoints\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--correlation` | ✅ | ρ (correlation) | 0.5 |\r\n| `--effect` | ✅ | Cohen's d | 0.3 |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test multiple_endpoints --effect 0.3 --correlation 0.5 -y\r\n```\r\n\r\n---\r\n\r\n### 20. `bayesian` — Bayesian\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--prob_control` | ✅ | control response probability | 0.3 |\r\n| `--prob_treatment` | ✅ | treatment response probability | 0.15 |\r\n| `--prior_a0` | | 0.5 | 0.5 |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test bayesian --prob_control 0.3 --prob_treatment 0.15 --prior_a0 0.5 -y\r\n```\r\n\r\n---\r\n\r\n### 21. `dose_escalation` — Dose escalation (Phase I)\r\n\r\n| Parameter | Description | Example |\r\n|:-----|:-----|\r\n| `--n_doses` | number of doses | 5 |\r\n| `--target_dlt` | target DLT rate, e.g. 0.33 | 0.33 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test dose_escalation --n_doses 5 --target_dlt 0.33 -y\r\n```\r\n\r\n---\r\n\r\n## Advanced Endpoints (v3.3)\r\n\r\n### 22. `win_ratio` — Win-Ratio\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--win_ratio_theta` | ✅ | Win-Ratio, e.g. 1.5 | 1.5 |\r\n| `--n_sim` | | 1000 | 1000 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test win_ratio --win_ratio_theta 1.5 --n_sim 1000 -y\r\n```\r\n\r\n---\r\n\r\n### 23. `must_win` — Must-Win\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--n_endpoints_must` | ✅ | 2-5 (default 3) | 3 |\r\n| `--effect_must` | ✅ | Cohen's d | 0.3 |\r\n| `--correlation_must` | ✅ | correlation | 0.5 |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test must_win --n_endpoints_must 3 --effect_must 0.3 --correlation_must 0.5 -y\r\n```\r\n\r\n---\r\n\r\n### 24. `historical_controls` — Historical controls\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--historical_response` | ✅ | historical responders | 15 |\r\n| `--historical_n` | ✅ | historical N | 100 |\r\n| `--a0_borrowing` | | 0-1 (default 0.5) | 0.5 |\r\n| `--p_control_current` | | 0.3 | 0.3 |\r\n| `--prob_treatment` | ✅ | 0.15 | 0.15 |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test historical_controls --historical_response 15 --historical_n 100 --a0_borrowing 0.5 --prob_treatment 0.15 -y\r\n```\r\n\r\n---\r\n\r\n### 25. `mams` — Multi-Arm Multi-Stage (MAMS)\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--n_arms_mams` | ✅ | 3 | 3 |\r\n| `--n_stages_mams` | ✅ | 2 | 2 |\r\n| `--delta_effect` | ✅ | effect | 0.3 |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test mams --n_arms_mams 3 --n_stages_mams 2 --delta_effect 0.3 -y\r\n```\r\n\r\n---\r\n\r\n### 26. `conditional_power` — Conditional power / SSR\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--timing` | ✅ | 0-1 (default 0.5) | 0.5 |\r\n| `--observed_effect` | ✅ | observed effect | 0.2 |\r\n| `--planned_effect` | ✅ | planned effect | 0.3 |\r\n| `--n_completed` | | 100 | 100 |\r\n| `--n_planned` | ✅ | 200 | 200 |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test conditional_power --timing 0.5 --observed_effect 0.2 --planned_effect 0.3 -y\r\n```\r\n\r\n---\r\n\r\n### 27. `superiority_margin` — Binary\r\n\r\nSee section 9 (`superiority_margin`) for the binary superiority-by-a-margin parameters (`--sup_margin`, `--p_control_sup`, `--delta_sup`).\r\n\r\n---\r\n\r\n### 28. `assurance` — Bayesian assurance\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--shape1_trt` | ✅ | Beta α treatment, e.g. 3 | 3 |\r\n| `--shape2_trt` | ✅ | Beta β treatment, e.g. 7 | 7 |\r\n| `--shape1_ctrl` | ✅ | Beta α control, e.g. 3 | 3 |\r\n| `--shape2_ctrl` | ✅ | Beta β control, e.g. 7 | 7 |\r\n| `--n_assurance` | ✅ | 100 | 100 |\r\n| `--n_sim_assurance` | | 5000 | 5000 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test assurance --shape1_trt 3 --shape2_trt 7 --shape1_ctrl 3 --shape2_ctrl 7 --n_assurance 100 -y\r\n```\r\n\r\n---\r\n\r\n### 29. `dunnett` — Dunnett\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--n_groups_dunnett` | ✅ | 3 | 3 |\r\n| `--n_control_dunnett` | ✅ | 50 | 50 |\r\n| `--effect_dunnett` | ✅ | Cohen's d | 0.4 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test dunnett --n_groups_dunnett 3 --n_control_dunnett 50 --effect_dunnett 0.4 -y\r\n```\r\n\r\n---\r\n\r\n### 30. `mediation` — Mediation\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--a_path` | ✅ | a-path effect, e.g. 0.3 | 0.3 |\r\n| `--b_path` | ✅ | b-path effect, e.g. 0.3 | 0.3 |\r\n| `--sigma2_m` | | 1.0 | 1.0 |\r\n| `--sigma2_y` | | 1.0 | 1.0 |\r\n| `--power` | | 0.8 | 0.8 |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test mediation --a_path 0.3 --b_path 0.3 -y\r\n```\r\n\r\n---\r\n\r\n### 31. `group_sequential` — Group sequential\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--n_interim` | ✅ | 1 | 1 |\r\n| `--effect_gs` | ✅ | Cohen's d | 0.4 |\r\n| `--spending_func` | | \"OF\" \"Pocock\" \"WT\" | \"OF\" |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test group_sequential --n_interim 1 --effect_gs 0.4 -y\r\n```\r\n\r\n---\r\n\r\n### 32. `adaptive` — Adaptive\r\n\r\n| Parameter | Required | Description | Example |\r\n|:-----|:-----|:-----|\r\n| `--n_stages_adapt` | ✅ | 2 | 2 |\r\n| `--effect_adaptive` | ✅ | Cohen's d | 0.4 |\r\n| `--adaptive_type` | | \"SSR\" \"Population\" \"Combination\" | \"SSR\" |\r\n\r\n```bash\r\npython scripts/samplesize_power.py --test adaptive --n_stages_adapt 2 --effect_adaptive 0.4 -y\r\n```\r\n\r\n---\r\n\r\n## Dropout Adjustment\r\n\r\nAdjusted N = ceiling(N_calculated / (1 - dropout_rate))\r\n\r\nExample: N=100 with 10% dropout → N = ceiling(100 / 0.9) = 112\r\n\r\n---\r\n\r\n## Quick Test Selector\r\n\r\n```\r\nWhat is your primary endpoint?\r\n├── Continuous → ttest_ind / ttest_paired / anova / mixed_model\r\n├── Binary → proportion_two / non_inferiority / superiority_margin\r\n├── Survival → survival / survival_exact / ni_survival\r\n├── Diagnostic → roc / bland_altman\r\n├── Vaccine → vaccine_efficacy\r\n├── Phase I dose-finding → dose_escalation\r\n├── Complex designs → group_sequential / adaptive / mams / conditional_power\r\n├── Multiple endpoints → must_win / multiple_endpoints\r\n├── Bioequivalence → be_tost\r\n└── Other → win_ratio / historical_controls / assurance / dunnett / mediation\r\n```\n\nFile v5.8.0:references/default_figures.md\n\n# Default Figures (v5.6) — Full Specification\r\n\r\n> Extracted from SKILL.md (2026-08-30 slimming, §16.1). SKILL.md keeps only the summary; this file is the authoritative detail.\r\n\r\n**Every** method produces at least one figure. All generation happens **on the coze side** (v5.6); the local CLI is a thin client that only consumes coze-returned `figures[]`.\r\n\r\n## Layer model\r\n\r\n| Layer | What it produces | Where it runs | When |\r\n|:---|:---|:---|:---|\r\n| **coze R** (`coze_figure_layer.R`) | Exact default chart for **all 49** methods (native noncentral distributions) | coze workflow | primary — whenever coze computes the method |\r\n| **coze-internal `figure_kit.py`** | Same default charts (Python, stdlib only) | coze workflow | fallback — only if R produced no SVG (svglite missing / R error) |\r\n| **coze R engine** | Authoritative curves for the 9 curve solvers | coze workflow | whenever coze returns `figures[]` for a curve solver |\r\n\r\n> **Deployment boundary:** the R + figure_kit layer lives in `adapters/coze/scripts/` (the canonical coze-side mirror, which must always be kept at the latest version); the **coze platform deployment step is manual (user-side)**. Full deploy + fallback-chain guide → `adapters/coze/DEPLOY.md`.\r\n\r\n**Figure merge & dedup (2026-08-30):** coze-internal `samplesize.py::_run_figure_layer` appends default figures after engine figures. When an engine figure caption already contains \"curve/曲线\" (the default primary is redundant with the engine power-N curve), the default primary (`*_default_1.svg`) is **filtered out**. Result: engine-fig methods get engine figures only; engine-less methods get the default primary.\r\n\r\n**Allocation-ratio suite — local render filter (v5.7.1):** coze emits the `alloc_suite` four charts **unconditionally** for the 13 two-group methods — the coze side is unchanged and always returns the full figure set. The **local HTML render layer** (`adapters/rendering.py::render_html_report` + `scripts/samplesize_power.py::render_figures` / `_filter_alloc`) then **hides these four charts unless the user explicitly asks for an unequal allocation**: i.e. the CLI `--ratio` (allocation ratio k = n2/n1) is present and `!= 1`. If the request says nothing about allocation (no `--ratio`) or explicitly asks for 1:1 (`--ratio = 1`), the four allocation charts are suppressed in the rendered report/figures (coze still returned them). Effect-size fields whose names contain `ratio` (`hazard_ratio`, `rate_ratio`, `win_ratio_theta`, `sigma_ratio`, `gs_ratio`, and the method ids `odds_ratio` / `risk_ratio`) are **not** allocation ratios and never affect this filter.\r\n\r\n## How the R layer stays honest\r\n\r\nIt never re-derives a sample-size formula. It takes the R-returned anchor `(n*, power*)` and inverts the **family-level** noncentrality relation with R's native `pnorm`/`pt`/`pf`/`pchisq`, which is mathematically exact:\r\n\r\n| Family | Noncentrality scales as | Reference law | Members |\r\n|:---|:---|:---|:---|\r\n| `z` | `λ(n) = λ*·√(n/n*)` | Normal | rates, OR/RR, most survival, Poisson, Win-ratio… |\r\n| `t` | `ncp(n) = ncp*·√(n/n*)` | noncentral t | t-tests, Dunnett, cluster, MMRM, Bland-Altman, TOST |\r\n| `F` | `λ(n) = λ*·(n/n*)` | noncentral F | ANOVA |\r\n| `X` | `λ(n) = λ*·(n/n*)` | noncentral χ² | Cox with covariate |\r\n\r\nThe curve is **pinned through the R anchor exactly** (residual ≤ 1e-16, verified for all 49 methods at 3 anchors each). The Python `figure_kit.py` fallback uses the same family law with a self-implemented kernel (cross-checked against R 4.6.1); it is precise for large samples and approximate for n < 20 or methods with continuity correction. Every chart carries an **effect-size ±20 % sensitivity band**: the visible consequence of that assumption, drawn rather than hidden.\r\n\r\n> **Charts communicate; they do not compute.** Read trend and trade-offs off the figure; quote the R number (the red anchor dot) in the protocol.\r\n\r\n## Figure kinds\r\n\r\nMapped per method in `adapters/coze/scripts/coze_figure_layer.R::METHOD_FIGURES`, mirrored to `tests/coze_cases/_contract_index.json::default_figure` and `scripts/figure_kit.py::METHOD_FIGURES`:\r\n\r\n| Kind | Axis pair | Methods | Answers |\r\n|:---|:---|:---|:---|\r\n| `power_n` | N → Power | 20 (t-tests, rates, ROC, Win-ratio…) | how steeply does power fall if I recruit fewer |\r\n| `power_events` | Events → Power | 6 (survival family) | event-driven: what D buys me headroom |\r\n| `power_n_multi` | N → Power, one series per arm count | 5 (ANOVA, Dunnett, MAMS, multiple endpoints, dose escalation) | cost of adding an arm |\r\n| `margin_tradeoff` | margin multiple → Power | 4 (non-inferiority, superiority margin, equivalence, TOST) | what relaxing the margin buys |\r\n| `icc_sens` | ICC → Power | 2 (cluster, MMRM) | design-effect exposure to ICC mis-specification |\r\n| `gs_boundary` | information fraction → z boundary | 10 (all group-sequential / adaptive) | OBF vs Pocock spending, Lan-DeMets closed form |\r\n| `assurance_n` | N → Assurance | 2 (bayesian, assurance) | probability-of-success planning |\r\n| `alloc_suite` *(secondary, full by coze / filtered locally)* | allocation ratio k = n2/n1 | **13 two-group methods**, always returned by coze; **shown locally only when `--ratio != 1`** | what unequal allocation costs — 4 charts + lookup table |\r\n\r\n## Allocation-ratio suite (`alloc_suite`)\r\n\r\nThe v5.5 addition for unequal group sizes, rendered by `scripts/alloc_curve.py`.\r\n\r\n> **Local render filter (v5.7.1):** coze always returns this suite for the 13 two-group methods (coze-side code is untouched). The local render layer hides it **unless the user requests an unequal allocation** — `--ratio` present and `!= 1`. Silence about allocation, or an explicit 1:1 (`--ratio = 1`), means the charts are returned by coze but **hidden in the local HTML report and figure output**. The filter key is the figure caption containing `alloc` (e.g. `ctss alloc ttest ind 1`); effect-size `ratio` fields never trigger it.\r\n\r\n- **A** required total N vs ratio (U-shape, minimum at 1:1)\r\n- **B** power vs ratio at fixed N (inverted-U)\r\n- **C** iso-power contour in the (n1, n2) plane, tangent to the 1:1 diagonal — the geometric proof that equal allocation is optimal\r\n- **D** power loss stratified by effect size\r\n\r\nGoverning identity: `N(k)/N(1) = (1+k)²/(4k)` (Schoenfeld inflation), identical for means, proportions and log-rank.\r\n\r\nFour backends feed it: `ttest_ind` (noncentral t), `prop` (unpooled z), `logrank` (Schoenfeld), and **`z`** — a generic two-independent-group z family (`ncp = θ·√(n₁n₂/N)`) covering `poisson`, `vaccine_efficacy` and `win_ratio`. Those three have no common effect-size scale (rate ratio, VE, win ratio), so θ is **solved back from the R anchor** (`theta_from_anchor`) and the suite is pinned to the same anchor as the main chart — verified: θ reproduces the anchor to ≤1.1e-16, and `N(k)/N(1)` matches `(1+k)²/(4k)` to ≤4.4e-16.\r\n\r\n⚠️ **Proportions break the 1:1 rule.** For two rates the cost-minimising allocation is Neyman's `k* = √(p₂(1−p₂)/p₁(1−p₁))`, not 1. At p₁=0.10 vs p₂=0.30 that is k*=1.53 (n1:n2 = 2:3): **113 subjects instead of 118**, a 4.2 % saving *and* higher power. The optimal-ratio marker is therefore solved from the actual curve (ternary search), never hardcoded — otherwise the single most valuable case would be labelled wrong.\r\n\r\n## Env knobs\r\n\r\n`CTSS_FIGURE_DEBUG=1` prints why a figure was skipped · `CTSS_OUTPUT_DIR` relocates output · `CTSS_INLINE_WIDGET=1` restores inline markers (off by default).\r\n\r\n## Accuracy\r\n\r\nDistribution kernels cross-validated against R 4.6.1 — central χ²/F and noncentral χ² agree to ≤5e-13, noncentral F to ≤3e-10, `qf`/`qchisq` to ≤8e-11. Zero third-party dependencies (stdlib `math` only).\r\n\r\n## Dependencies: zero new R packages (a deploy step is required)\r\n\r\nAll figure generation runs on the coze side in v5.6, so the coze workflow must deploy the figure layer from `adapters/coze/scripts/` (4 files: `coze_figure_layer.R`, `figure_kit.py`, `alloc_curve.py`, `coze_fallback.py`) — but **no new R package is installed**: `svglite` is already in the tier1 list (`scripts/install_r_packages.R`) alongside `pwr`/`rpact`/`TrialSize`/`PowerTOST`/`powerSurvEpi`/`simr`/`lme4`/`survival`, which cover every statistic involved. The only two places a package *could* have helped (`clusterPower` for ICC, `bsurvival` for assurance) use closed-form approximations anchored to the R number instead, with the residual uncertainty drawn as the sensitivity band — cheaper than a new image build. Local side needs **no** figure dependencies at all (thin client).\n\nFile v5.8.0:references/drug_name_map.json\n\n{\r\n  \"_meta\": {\r\n    \"description\": \"中文药物名 → 标准英文 INN/通用名 映射表（用于 openFDA FAERS 检索预处理）\",\r\n    \"version\": \"1.1\",\r\n    \"updated\": \"2026-09-06\",\r\n    \"note\": \"一个中文名可对应多个英文名（如复方制剂、不同盐基）；检索时多候选列出让用户确认。仅覆盖常见药，不在表中时提示用户手动输入英文名。\"\r\n  },\r\n  \"阿司匹林\": [\r\n    \"aspirin\"\r\n  ],\r\n  \"布洛芬\": [\r\n    \"ibuprofen\"\r\n  ],\r\n  \"对乙酰氨基酚\": [\r\n    \"acetaminophen\",\r\n    \"paracetamol\"\r\n  ],\r\n  \"阿莫西林\": [\r\n    \"amoxicillin\"\r\n  ],\r\n  \"头孢氨苄\": [\r\n    \"cefalexin\",\r\n    \"cephalexin\"\r\n  ],\r\n  \"头孢呋辛\": [\r\n    \"cefuroxime\"\r\n  ],\r\n  \"头孢曲松\": [\r\n    \"ceftriaxone\"\r\n  ],\r\n  \"阿奇霉素\": [\r\n    \"azithromycin\"\r\n  ],\r\n  \"克拉霉素\": [\r\n    \"clarithromycin\"\r\n  ],\r\n  \"左氧氟沙星\": [\r\n    \"levofloxacin\"\r\n  ],\r\n  \"莫西沙星\": [\r\n    \"moxifloxacin\"\r\n  ],\r\n  \"甲硝唑\": [\r\n    \"metronidazole\"\r\n  ],\r\n  \"奥美拉唑\": [\r\n    \"omeprazole\"\r\n  ],\r\n  \"兰索拉唑\": [\r\n    \"lansoprazole\"\r\n  ],\r\n  \"泮托拉唑\": [\r\n    \"pantoprazole\"\r\n  ],\r\n  \"雷贝拉唑\": [\r\n    \"rabeprazole\"\r\n  ],\r\n  \"艾司奥美拉唑\": [\r\n    \"esomeprazole\"\r\n  ],\r\n  \"法莫替丁\": [\r\n    \"famotidine\"\r\n  ],\r\n  \"雷尼替丁\": [\r\n    \"ranitidine\"\r\n  ],\r\n  \"西咪替丁\": [\r\n    \"cimetidine\"\r\n  ],\r\n  \"二甲双胍\": [\r\n    \"metformin\"\r\n  ],\r\n  \"格列美脲\": [\r\n    \"glimepiride\"\r\n  ],\r\n  \"格列齐特\": [\r\n    \"gliclazide\"\r\n  ],\r\n  \"格列吡嗪\": [\r\n    \"glipizide\"\r\n  ],\r\n  \"格列本脲\": [\r\n    \"glibenclamide\",\r\n    \"glyburide\"\r\n  ],\r\n  \"阿卡波糖\": [\r\n    \"acarbose\"\r\n  ],\r\n  \"伏格列波糖\": [\r\n    \"voglibose\"\r\n  ],\r\n  \"瑞格列奈\": [\r\n    \"repaglinide\"\r\n  ],\r\n  \"那格列奈\": [\r\n    \"nateglinide\"\r\n  ],\r\n  \"西格列汀\": [\r\n    \"sitagliptin\"\r\n  ],\r\n  \"沙格列汀\": [\r\n    \"saxagliptin\"\r\n  ],\r\n  \"利格列汀\": [\r\n    \"linagliptin\"\r\n  ],\r\n  \"维格列汀\": [\r\n    \"vildagliptin\"\r\n  ],\r\n  \"恩格列净\": [\r\n    \"empagliflozin\"\r\n  ],\r\n  \"达格列净\": [\r\n    \"dapagliflozin\"\r\n  ],\r\n  \"卡格列净\": [\r\n    \"canagliflozin\"\r\n  ],\r\n  \"吡格列酮\": [\r\n    \"pioglitazone\"\r\n  ],\r\n  \"罗格列酮\": [\r\n    \"rosiglitazone\"\r\n  ],\r\n  \"胰岛素\": [\r\n    \"insulin\"\r\n  ],\r\n  \"甘精胰岛素\": [\r\n    \"insulin glargine\"\r\n  ],\r\n  \"门冬胰岛素\": [\r\n    \"insulin aspart\"\r\n  ],\r\n  \"赖脯胰岛素\": [\r\n    \"insulin lispro\"\r\n  ],\r\n  \"地特胰岛素\": [\r\n    \"insulin detemir\"\r\n  ],\r\n  \"格列喹酮\": [\r\n    \"gliquidone\"\r\n  ],\r\n  \"阿托伐他汀\": [\r\n    \"atorvastatin\"\r\n  ],\r\n  \"瑞舒伐他汀\": [\r\n    \"rosuvastatin\"\r\n  ],\r\n  \"辛伐他汀\": [\r\n    \"simvastatin\"\r\n  ],\r\n  \"普伐他汀\": [\r\n    \"pravastatin\"\r\n  ],\r\n  \"氟伐他汀\": [\r\n    \"fluvastatin\"\r\n  ],\r\n  \"匹伐他汀\": [\r\n    \"pitavastatin\"\r\n  ],\r\n  \"洛伐他汀\": [\r\n    \"lovastatin\"\r\n  ],\r\n  \"依折麦布\": [\r\n    \"ezetimibe\"\r\n  ],\r\n  \"非诺贝特\": [\r\n    \"fenofibrate\"\r\n  ],\r\n  \"吉非贝齐\": [\r\n    \"gemfibrozil\"\r\n  ],\r\n  \"苯扎贝特\": [\r\n    \"bezafibrate\"\r\n  ],\r\n  \"考来烯胺\": [\r\n    \"cholestyramine\"\r\n  ],\r\n  \"阿昔单抗\": [\r\n    \"abciximab\"\r\n  ],\r\n  \"氯吡格雷\": [\r\n    \"clopidogrel\"\r\n  ],\r\n  \"替格瑞洛\": [\r\n    \"ticagrelor\"\r\n  ],\r\n  \"普拉格雷\": [\r\n    \"prasugrel\"\r\n  ],\r\n  \"华法林\": [\r\n    \"warfarin\"\r\n  ],\r\n  \"利伐沙班\": [\r\n    \"rivaroxaban\"\r\n  ],\r\n  \"阿哌沙班\": [\r\n    \"apixaban\"\r\n  ],\r\n  \"达比加群\": [\r\n    \"dabigatran\"\r\n  ],\r\n  \"依度沙班\": [\r\n    \"edoxaban\"\r\n  ],\r\n  \"肝素\": [\r\n    \"heparin\"\r\n  ],\r\n  \"低分子肝素\": [\r\n    \"enoxaparin\",\r\n    \"low molecular weight heparin\"\r\n  ],\r\n  \"达肝素\": [\r\n    \"dalteparin\"\r\n  ],\r\n  \"那屈肝素\": [\r\n    \"nadroparin\"\r\n  ],\r\n  \"磺达肝癸钠\": [\r\n    \"fondaparinux\"\r\n  ],\r\n  \"阿替普酶\": [\r\n    \"alteplase\"\r\n  ],\r\n  \"尿激酶\": [\r\n    \"urokinase\"\r\n  ],\r\n  \"链激酶\": [\r\n    \"streptokinase\"\r\n  ],\r\n  \"氨甲环酸\": [\r\n    \"tranexamic acid\"\r\n  ],\r\n  \"氨基己酸\": [\r\n    \"aminocaproic acid\"\r\n  ],\r\n  \"鱼精蛋白\": [\r\n    \"protamine\"\r\n  ],\r\n  \"维生素K\": [\r\n    \"vitamin k\",\r\n    \"phytomenadione\"\r\n  ],\r\n  \"酚磺乙胺\": [\r\n    \"etamsylate\"\r\n  ],\r\n  \"卡巴克络\": [\r\n    \"carbazochrome\"\r\n  ],\r\n  \"硝苯地平\": [\r\n    \"nifedipine\"\r\n  ],\r\n  \"氨氯地平\": [\r\n    \"amlodipine\"\r\n  ],\r\n  \"非洛地平\": [\r\n    \"felodipine\"\r\n  ],\r\n  \"拉西地平\": [\r\n    \"lacidipine\"\r\n  ],\r\n  \"尼群地平\": [\r\n    \"nitrendipine\"\r\n  ],\r\n  \"尼莫地平\": [\r\n    \"nimodipine\"\r\n  ],\r\n  \"地尔硫卓\": [\r\n    \"diltiazem\"\r\n  ],\r\n  \"维拉帕米\": [\r\n    \"verapamil\"\r\n  ],\r\n  \"卡托普利\": [\r\n    \"captopril\"\r\n  ],\r\n  \"依那普利\": [\r\n    \"enalapril\"\r\n  ],\r\n  \"贝那普利\": [\r\n    \"benazepril\"\r\n  ],\r\n  \"培哚普利\": [\r\n    \"perindopril\"\r\n  ],\r\n  \"雷米普利\": [\r\n    \"ramipril\"\r\n  ],\r\n  \"福辛普利\": [\r\n    \"fosinopril\"\r\n  ],\r\n  \"西拉普利\": [\r\n    \"cilazapril\"\r\n  ],\r\n  \"赖诺普利\": [\r\n    \"lisinopril\"\r\n  ],\r\n  \"氯沙坦\": [\r\n    \"losartan\"\r\n  ],\r\n  \"缬沙坦\": [\r\n    \"valsartan\"\r\n  ],\r\n  \"厄贝沙坦\": [\r\n    \"irbesartan\"\r\n  ],\r\n  \"替米沙坦\": [\r\n    \"telmisartan\"\r\n  ],\r\n  \"坎地沙坦\": [\r\n    \"candesartan\"\r\n  ],\r\n  \"奥美沙坦\": [\r\n    \"olmesartan\"\r\n  ],\r\n  \"阿利沙坦\": [\r\n    \"allisartan\"\r\n  ],\r\n  \"氢氯噻嗪\": [\r\n    \"hydrochlorothiazide\"\r\n  ],\r\n  \"呋塞米\": [\r\n    \"furosemide\"\r\n  ],\r\n  \"托拉塞米\": [\r\n    \"torasemide\"\r\n  ],\r\n  \"螺内酯\": [\r\n    \"spironolactone\"\r\n  ],\r\n  \"氨苯蝶啶\": [\r\n    \"triamterene\"\r\n  ],\r\n  \"阿米洛利\": [\r\n    \"amiloride\"\r\n  ],\r\n  \"吲达帕胺\": [\r\n    \"indapamide\"\r\n  ],\r\n  \"美托洛尔\": [\r\n    \"metoprolol\"\r\n  ],\r\n  \"比索洛尔\": [\r\n    \"bisoprolol\"\r\n  ],\r\n  \"阿替洛尔\": [\r\n    \"atenolol\"\r\n  ],\r\n  \"普萘洛尔\": [\r\n    \"propranolol\"\r\n  ],\r\n  \"卡维地洛\": [\r\n    \"carvedilol\"\r\n  ],\r\n  \"拉贝洛尔\": [\r\n    \"labetalol\"\r\n  ],\r\n  \"艾司洛尔\": [\r\n    \"esmolol\"\r\n  ],\r\n  \"富马酸比索洛尔\": [\r\n    \"bisoprolol\"\r\n  ],\r\n  \"琥珀酸美托洛尔\": [\r\n    \"metoprolol succinate\"\r\n  ],\r\n  \"酒石酸美托洛尔\": [\r\n    \"metoprolol tartrate\"\r\n  ],\r\n  \"地高辛\": [\r\n    \"digoxin\"\r\n  ],\r\n  \"去乙酰毛花苷\": [\r\n    \"deslanoside\"\r\n  ],\r\n  \"胺碘酮\": [\r\n    \"amiodarone\"\r\n  ],\r\n  \"普罗帕酮\": [\r\n    \"propafenone\"\r\n  ],\r\n  \"利多卡因\": [\r\n    \"lidocaine\"\r\n  ],\r\n  \"腺苷\": [\r\n    \"adenosine\"\r\n  ],\r\n  \"阿托品\": [\r\n    \"atropine\"\r\n  ],\r\n  \"异丙肾上腺素\": [\r\n    \"isoprenaline\",\r\n    \"isoproterenol\"\r\n  ],\r\n  \"肾上腺素\": [\r\n    \"epinephrine\",\r\n    \"adrenaline\"\r\n  ],\r\n  \"去甲肾上腺素\": [\r\n    \"norepinephrine\",\r\n    \"noradrenaline\"\r\n  ],\r\n  \"多巴胺\": [\r\n    \"dopamine\"\r\n  ],\r\n  \"多巴酚丁胺\": [\r\n    \"dobutamine\"\r\n  ],\r\n  \"米力农\": [\r\n    \"milrinone\"\r\n  ],\r\n  \"左西孟旦\": [\r\n    \"levosimendan\"\r\n  ],\r\n  \"硝酸甘油\": [\r\n    \"nitroglycerin\"\r\n  ],\r\n  \"单硝酸异山梨酯\": [\r\n    \"isosorbide mononitrate\"\r\n  ],\r\n  \"硝酸异山梨酯\": [\r\n    \"isosorbide dinitrate\"\r\n  ],\r\n  \"尼可地尔\": [\r\n    \"nicorandil\"\r\n  ],\r\n  \"曲美他嗪\": [\r\n    \"trimetazidine\"\r\n  ],\r\n  \"尼可刹米\": [\r\n    \"nikethamide\"\r\n  ],\r\n  \"洛贝林\": [\r\n    \"lobeline\"\r\n  ],\r\n  \"咖啡因\": [\r\n    \"caffeine\"\r\n  ],\r\n  \"二甲硅油\": [\r\n    \"dimeticone\"\r\n  ],\r\n  \"酚妥拉明\": [\r\n    \"phentolamine\"\r\n  ],\r\n  \"酚苄明\": [\r\n    \"phenoxybenzamine\"\r\n  ],\r\n  \"利血平\": [\r\n    \"reserpine\"\r\n  ],\r\n  \"硫酸镁\": [\r\n    \"magnesium sulfate\"\r\n  ],\r\n  \"葡萄糖酸钙\": [\r\n    \"calcium gluconate\"\r\n  ],\r\n  \"氯化钾\": [\r\n    \"potassium chloride\"\r\n  ],\r\n  \"氯化钠\": [\r\n    \"sodium chloride\"\r\n  ],\r\n  \"葡萄糖\": [\r\n    \"glucose\"\r\n  ],\r\n  \"乳果糖\": [\r\n    \"lactulose\"\r\n  ],\r\n  \"聚乙二醇\": [\r\n    \"polyethylene glycol\"\r\n  ],\r\n  \"双歧杆菌\": [\r\n    \"bifidobacterium\"\r\n  ],\r\n  \"枯草杆菌\": [\r\n    \"bacillus subtilis\"\r\n  ],\r\n  \"蒙脱石\": [\r\n    \"smectite\"\r\n  ],\r\n  \"洛哌丁胺\": [\r\n    \"loperamide\"\r\n  ],\r\n  \"奥曲肽\": [\r\n    \"octreotide\"\r\n  ],\r\n  \"生长抑素\": [\r\n    \"somatostatin\"\r\n  ],\r\n  \"垂体后叶素\": [\r\n    \"pituitrin\"\r\n  ],\r\n  \"缩宫素\": [\r\n    \"oxytocin\"\r\n  ],\r\n  \"麦角新碱\": [\r\n    \"ergometrine\"\r\n  ],\r\n  \"卡前列素\": [\r\n    \"carboprost\"\r\n  ],\r\n  \"米索前列醇\": [\r\n    \"misoprostol\"\r\n  ],\r\n  \"地诺前列酮\": [\r\n    \"dinoprostone\"\r\n  ],\r\n  \"利托君\": [\r\n    \"ritodrine\"\r\n  ],\r\n  \"硫酸沙丁胺醇\": [\r\n    \"salbutamol\"\r\n  ],\r\n  \"特布他林\": [\r\n    \"terbutaline\"\r\n  ],\r\n  \"异丙托溴铵\": [\r\n    \"ipratropium bromide\"\r\n  ],\r\n  \"噻托溴铵\": [\r\n    \"tiotropium bromide\"\r\n  ],\r\n  \"布地奈德\": [\r\n    \"budesonide\"\r\n  ],\r\n  \"丙酸氟替卡松\": [\r\n    \"fluticasone propionate\"\r\n  ],\r\n  \"沙美特罗\": [\r\n    \"salmeterol\"\r\n  ],\r\n  \"福莫特罗\": [\r\n    \"formoterol\"\r\n  ],\r\n  \"孟鲁司特\": [\r\n    \"montelukast\"\r\n  ],\r\n  \"扎鲁司特\": [\r\n    \"zafirlukast\"\r\n  ],\r\n  \"齐留通\": [\r\n    \"zileuton\"\r\n  ],\r\n  \"色甘酸钠\": [\r\n    \"sodium cromoglicate\"\r\n  ],\r\n  \"多索茶碱\": [\r\n    \"doxofylline\"\r\n  ],\r\n  \"氨茶碱\": [\r\n    \"aminophylline\"\r\n  ],\r\n  \"二羟丙茶碱\": [\r\n    \"dyphylline\"\r\n  ],\r\n  \"乙酰半胱氨酸\": [\r\n    \"acetylcysteine\"\r\n  ],\r\n  \"羧甲司坦\": [\r\n    \"carbocisteine\"\r\n  ],\r\n  \"盐酸氨溴索\": [\r\n    \"ambroxol\"\r\n  ],\r\n  \"溴己新\": [\r\n    \"bromhexine\"\r\n  ],\r\n  \"桉柠蒎\": [\r\n    \"eucalyptus\"\r\n  ],\r\n  \"标准桃金娘油\": [\r\n    \"myrtol\"\r\n  ],\r\n  \"可待因\": [\r\n    \"codeine\"\r\n  ],\r\n  \"福尔可定\": [\r\n    \"pholcodine\"\r\n  ],\r\n  \"右美沙芬\": [\r\n    \"dextromethorphan\"\r\n  ],\r\n  \"喷托维林\": [\r\n    \"pentoxyverine\"\r\n  ],\r\n  \"氯哌斯汀\": [\r\n    \"cloperastine\"\r\n  ],\r\n  \"复方甘草\": [\r\n    \"glycyrrhiza\"\r\n  ],\r\n  \"阿桔片\": [\r\n    \"platycodon\"\r\n  ],\r\n  \"苯丙哌林\": [\r\n    \"properidine\"\r\n  ],\r\n  \"二氧丙嗪\": [\r\n    \"dioxopromethazine\"\r\n  ],\r\n  \"异丙嗪\": [\r\n    \"promethazine\"\r\n  ],\r\n  \"氯苯那敏\": [\r\n    \"chlorpheniramine\"\r\n  ],\r\n  \"苯海拉明\": [\r\n    \"diphenhydramine\"\r\n  ],\r\n  \"赛庚啶\": [\r\n    \"cyproheptadine\"\r\n  ],\r\n  \"酮替芬\": [\r\n    \"ketotifen\"\r\n  ],\r\n  \"西替利嗪\": [\r\n    \"cetirizine\"\r\n  ],\r\n  \"氯雷他定\": [\r\n    \"loratadine\"\r\n  ],\r\n  \"依巴斯汀\": [\r\n    \"ebastine\"\r\n  ],\r\n  \"咪唑斯汀\": [\r\n    \"mizolastine\"\r\n  ],\r\n  \"氮卓斯汀\": [\r\n    \"azelastine\"\r\n  ],\r\n  \"非索非那定\": [\r\n    \"fexofenadine\"\r\n  ],\r\n  \"地氯雷他定\": [\r\n    \"desloratadine\"\r\n  ],\r\n  \"左西替利嗪\": [\r\n    \"levocetirizine\"\r\n  ],\r\n  \"奥洛他定\": [\r\n    \"olopatadine\"\r\n  ],\r\n  \"阿伐斯汀\": [\r\n    \"acrivastine\"\r\n  ],\r\n  \"曲普利啶\": [\r\n    \"triprolidine\"\r\n  ],\r\n  \"阿司咪唑\": [\r\n    \"astemizole\"\r\n  ],\r\n  \"特非那定\": [\r\n    \"terfenadine\"\r\n  ],\r\n  \"卡马西平\": [\r\n    \"carbamazepine\"\r\n  ],\r\n  \"苯妥英钠\": [\r\n    \"phenytoin sodium\"\r\n  ],\r\n  \"丙戊酸钠\": [\r\n    \"sodium valproate\"\r\n  ],\r\n  \"苯巴比妥\": [\r\n    \"phenobarbital\"\r\n  ],\r\n  \"拉莫三嗪\": [\r\n    \"lamotrigine\"\r\n  ],\r\n  \"左乙拉西坦\": [\r\n    \"levetiracetam\"\r\n  ],\r\n  \"奥卡西平\": [\r\n    \"oxcarbazepine\"\r\n  ],\r\n  \"托吡酯\": [\r\n    \"topiramate\"\r\n  ],\r\n  \"加巴喷丁\": [\r\n    \"gabapentin\"\r\n  ],\r\n  \"普瑞巴林\": [\r\n    \"pregabalin\"\r\n  ],\r\n  \"乙琥胺\": [\r\n    \"ethosuximide\"\r\n  ],\r\n  \"氯硝西泮\": [\r\n    \"clonazepam\"\r\n  ],\r\n  \"地西泮\": [\r\n    \"diazepam\"\r\n  ],\r\n  \"硝西泮\": [\r\n    \"nitrazepam\"\r\n  ],\r\n  \"艾司唑仑\": [\r\n    \"estazolam\"\r\n  ],\r\n  \"阿普唑仑\": [\r\n    \"alprazolam\"\r\n  ],\r\n  \"劳拉西泮\": [\r\n    \"lorazepam\"\r\n  ],\r\n  \"咪达唑仑\": [\r\n    \"midazolam\"\r\n  ],\r\n  \"唑吡坦\": [\r\n    \"zolpidem\"\r\n  ],\r\n  \"佐匹克隆\": [\r\n    \"zopiclone\"\r\n  ],\r\n  \"扎来普隆\": [\r\n    \"zaleplon\"\r\n  ],\r\n  \"水合氯醛\": [\r\n    \"chloral hydrate\"\r\n  ],\r\n  \"丁螺环酮\": [\r\n    \"buspirone\"\r\n  ],\r\n  \"坦度螺酮\": [\r\n    \"tandospirone\"\r\n  ],\r\n  \"氟西汀\": [\r\n    \"fluoxetine\"\r\n  ],\r\n  \"帕罗西汀\": [\r\n    \"paroxetine\"\r\n  ],\r\n  \"舍曲林\": [\r\n    \"sertraline\"\r\n  ],\r\n  \"氟伏沙明\": [\r\n    \"fluvoxamine\"\r\n  ],\r\n  \"西酞普兰\": [\r\n    \"citalopram\"\r\n  ],\r\n  \"艾司西酞普兰\": [\r\n    \"escitalopram\"\r\n  ],\r\n  \"文拉法辛\": [\r\n    \"venlafaxine\"\r\n  ],\r\n  \"度洛西汀\": [\r\n    \"duloxetine\"\r\n  ],\r\n  \"米那普仑\": [\r\n    \"milnacipran\"\r\n  ],\r\n  \"米氮平\": [\r\n    \"mirtazapine\"\r\n  ],\r\n  \"阿戈美拉汀\": [\r\n    \"agomelatine\"\r\n  ],\r\n  \"安非他酮\": [\r\n    \"bupropion\"\r\n  ],\r\n  \"瑞波西汀\": [\r\n    \"reboxetine\"\r\n  ],\r\n  \"曲唑酮\": [\r\n    \"trazodone\"\r\n  ],\r\n  \"奈法唑酮\": [\r\n    \"nefazodone\"\r\n  ],\r\n  \"吗氯贝胺\": [\r\n    \"moclobemide\"\r\n  ],\r\n  \"苯乙肼\": [\r\n    \"phenelzine\"\r\n  ],\r\n  \"反苯环丙胺\": [\r\n    \"tranylcypromine\"\r\n  ],\r\n  \"碳酸锂\": [\r\n    \"lithium carbonate\"\r\n  ],\r\n  \"奥氮平\": [\r\n    \"olanzapine\"\r\n  ],\r\n  \"喹硫平\": [\r\n    \"quetiapine\"\r\n  ],\r\n  \"利培酮\": [\r\n    \"risperidone\"\r\n  ],\r\n  \"帕利哌酮\": [\r\n    \"paliperidone\"\r\n  ],\r\n  \"齐拉西酮\": [\r\n    \"ziprasidone\"\r\n  ],\r\n  \"阿立哌唑\": [\r\n    \"aripiprazole\"\r\n  ],\r\n  \"鲁拉西酮\": [\r\n    \"lurasidone\"\r\n  ],\r\n  \"布南色尔\": [\r\n    \"blonanserin\"\r\n  ],\r\n  \"氨磺必利\": [\r\n    \"amisulpride\"\r\n  ],\r\n  \"氯氮平\": [\r\n    \"clozapine\"\r\n  ],\r\n  \"氟哌啶醇\": [\r\n    \"haloperidol\"\r\n  ],\r\n  \"奋乃静\": [\r\n    \"perphenazine\"\r\n  ],\r\n  \"氟奋乃静\": [\r\n    \"fluphenazine\"\r\n  ],\r\n  \"三氟拉嗪\": [\r\n    \"trifluoperazine\"\r\n  ],\r\n  \"硫必利\": [\r\n    \"tiapride\"\r\n  ],\r\n  \"舒必利\": [\r\n    \"sulpiride\"\r\n  ],\r\n  \"左舒必利\": [\r\n    \"levosulpiride\"\r\n  ],\r\n  \"扑米酮\": [\r\n    \"primidone\"\r\n  ],\r\n  \"拉考沙胺\": [\r\n    \"lacosamide\"\r\n  ],\r\n  \"吡仑帕奈\": [\r\n    \"perampanel\"\r\n  ],\r\n  \"司替戊醇\": [\r\n    \"stiripentol\"\r\n  ],\r\n  \"卡立普多\": [\r\n    \"carisoprodol\"\r\n  ],\r\n  \"巴氯芬\": [\r\n    \"baclofen\"\r\n  ],\r\n  \"替扎尼定\": [\r\n    \"tizanidine\"\r\n  ],\r\n  \"丹曲林\": [\r\n    \"dantrolene\"\r\n  ],\r\n  \"乙哌立松\": [\r\n    \"eperisone\"\r\n  ],\r\n  \"苯海索\": [\r\n    \"trihexyphenidyl\"\r\n  ],\r\n  \"丙环定\": [\r\n    \"procyclidine\"\r\n  ],\r\n  \"左旋多巴\": [\r\n    \"levodopa\"\r\n  ],\r\n  \"卡比多巴\": [\r\n    \"carbidopa\"\r\n  ],\r\n  \"恩他卡朋\": [\r\n    \"entacapone\"\r\n  ],\r\n  \"托卡朋\": [\r\n    \"tolcapone\"\r\n  ],\r\n  \"司来吉兰\": [\r\n    \"selegiline\"\r\n  ],\r\n  \"雷沙吉兰\": [\r\n    \"rasagiline\"\r\n  ],\r\n  \"金刚烷胺\": [\r\n    \"amantadine\"\r\n  ],\r\n  \"普拉克索\": [\r\n    \"pramipexole\"\r\n  ],\r\n  \"罗匹尼罗\": [\r\n    \"ropinirole\"\r\n  ],\r\n  \"罗替高汀\": [\r\n    \"rotigotine\"\r\n  ],\r\n  \"培高利特\": [\r\n    \"pergolide\"\r\n  ],\r\n  \"阿扑吗啡\": [\r\n    \"apomorphine\"\r\n  ],\r\n  \"多奈哌齐\": [\r\n    \"donepezil\"\r\n  ],\r\n  \"卡巴拉汀\": [\r\n    \"rivastigmine\"\r\n  ],\r\n  \"加兰他敏\": [\r\n    \"galantamine\"\r\n  ],\r\n  \"美金刚\": [\r\n    \"memantine\"\r\n  ],\r\n  \"尼麦角林\": [\r\n    \"nicergoline\"\r\n  ],\r\n  \"倍他司汀\": [\r\n    \"betahistine\"\r\n  ],\r\n  \"氟桂利嗪\": [\r\n    \"flunarizine\"\r\n  ],\r\n  \"桂利嗪\": [\r\n    \"cinnarizine\"\r\n  ],\r\n  \"罂粟碱\": [\r\n    \"papaverine\"\r\n  ],\r\n  \"川芎嗪\": [\r\n    \"ligustrazine\"\r\n  ],\r\n  \"丁苯酞\": [\r\n    \"dl-3-n-butylphthalide\"\r\n  ],\r\n  \"依达拉奉\": [\r\n    \"edaravone\"\r\n  ],\r\n  \"脑苷肌苷\": [\r\n    \"cattle encephaloglycan\"\r\n  ],\r\n  \"鼠神经生长因子\": [\r\n    \"mouse nerve growth factor\"\r\n  ],\r\n  \"奥拉西坦\": [\r\n    \"oxiracetam\"\r\n  ],\r\n  \"吡拉西坦\": [\r\n    \"piracetam\"\r\n  ],\r\n  \"胞磷胆碱\": [\r\n    \"citicoline\"\r\n  ],\r\n  \"神经节苷脂\": [\r\n    \"ganglioside\"\r\n  ],\r\n  \"艾地苯醌\": [\r\n    \"idebenone\"\r\n  ],\r\n  \"维生素B1\": [\r\n    \"vitamin b1\",\r\n    \"thiamine\"\r\n  ],\r\n  \"维生素B2\": [\r\n    \"vitamin b2\",\r\n    \"riboflavin\"\r\n  ],\r\n  \"维生素B6\": [\r\n    \"vitamin b6\",\r\n    \"pyridoxine\"\r\n  ],\r\n  \"维生素B12\": [\r\n    \"vitamin b12\",\r\n    \"cyanocobalamin\"\r\n  ],\r\n  \"维生素C\": [\r\n    \"vitamin c\",\r\n    \"ascorbic acid\"\r\n  ],\r\n  \"维生素D\": [\r\n    \"vitamin d\",\r\n    \"cholecalciferol\"\r\n  ],\r\n  \"维生素E\": [\r\n    \"vitamin e\",\r\n    \"tocopherol\"\r\n  ],\r\n  \"维生素K1\": [\r\n    \"vitamin k1\",\r\n    \"phytomenadione\"\r\n  ],\r\n  \"叶酸\": [\r\n    \"folic acid\"\r\n  ],\r\n  \"烟酸\": [\r\n    \"niacin\",\r\n    \"nicotinic acid\"\r\n  ],\r\n  \"烟酰胺\": [\r\n    \"niacinamide\"\r\n  ],\r\n  \"复合维生素B\": [\r\n    \"vitamin b complex\"\r\n  ],\r\n  \"葡萄糖酸锌\": [\r\n    \"zinc gluconate\"\r\n  ],\r\n  \"硫酸亚铁\": [\r\n    \"ferrous sulfate\"\r\n  ],\r\n  \"富马酸亚铁\": [\r\n    \"ferrous fumarate\"\r\n  ],\r\n  \"琥珀酸亚铁\": [\r\n    \"ferrous succinate\"\r\n  ],\r\n  \"多糖铁复合物\": [\r\n    \"polysaccharide iron complex\"\r\n  ],\r\n  \"右旋糖酐铁\": [\r\n    \"iron dextran\"\r\n  ],\r\n  \"蔗糖铁\": [\r\n    \"iron sucrose\"\r\n  ],\r\n  \"重组人促红素\": [\r\n    \"erythropoietin\"\r\n  ],\r\n  \"聚乙二醇化重组人粒细胞集落刺激因子\": [\r\n    \"pegfilgrastim\"\r\n  ],\r\n  \"重组人粒细胞集落刺激因子\": [\r\n    \"filgrastim\"\r\n  ],\r\n  \"粒细胞-巨噬细胞集落刺激因子\": [\r\n    \"sargramostim\"\r\n  ],\r\n  \"白介素-2\": [\r\n    \"interleukin-2\"\r\n  ],\r\n  \"白介素-11\": [\r\n    \"interleukin-11\"\r\n  ],\r\n  \"干扰素\": [\r\n    \"interferon\"\r\n  ],\r\n  \"聚乙二醇干扰素\": [\r\n    \"peginterferon\"\r\n  ],\r\n  \"利巴韦林\": [\r\n    \"ribavirin\"\r\n  ],\r\n  \"阿昔洛韦\": [\r\n    \"acyclovir\"\r\n  ],\r\n  \"更昔洛韦\": [\r\n    \"ganciclovir\"\r\n  ],\r\n  \"伐昔洛韦\": [\r\n    \"valacyclovir\"\r\n  ],\r\n  \"泛昔洛韦\": [\r\n    \"famciclovir\"\r\n  ],\r\n  \"膦甲酸钠\": [\r\n    \"foscarnet sodium\"\r\n  ],\r\n  \"奥司他韦\": [\r\n    \"oseltamivir\"\r\n  ],\r\n  \"扎那米韦\": [\r\n    \"zanamivir\"\r\n  ],\r\n  \"帕拉米韦\": [\r\n    \"peramivir\"\r\n  ],\r\n  \"法匹拉韦\": [\r\n    \"favipiravir\"\r\n  ],\r\n  \"瑞德西韦\": [\r\n    \"remdesivir\"\r\n  ],\r\n  \"莫诺拉韦\": [\r\n    \"molnupiravir\"\r\n  ],\r\n  \"奈玛特韦\": [\r\n    \"nirmatrelvir\"\r\n  ],\r\n  \"利托那韦\": [\r\n    \"ritonavir\"\r\n  ],\r\n  \"洛匹那韦\": [\r\n    \"lopinavir\"\r\n  ],\r\n  \"达芦那韦\": [\r\n    \"darunavir\"\r\n  ],\r\n  \"阿扎那韦\": [\r\n    \"atazanavir\"\r\n  ],\r\n  \"拉替拉韦\": [\r\n    \"raltegravir\"\r\n  ],\r\n  \"多替拉韦\": [\r\n    \"dolutegravir\"\r\n  ],\r\n  \"艾维雷韦\": [\r\n    \"elvitegravir\"\r\n  ],\r\n  \"比克替拉韦\": [\r\n    \"bictegravir\"\r\n  ],\r\n  \"恩曲他滨\": [\r\n    \"emtricitabine\"\r\n  ],\r\n  \"替诺福韦\": [\r\n    \"tenofovir\"\r\n  ],\r\n  \"恩替卡韦\": [\r\n    \"entecavir\"\r\n  ],\r\n  \"拉米夫定\": [\r\n    \"lamivudine\"\r\n  ],\r\n  \"阿德福韦\": [\r\n    \"adefovir\"\r\n  ],\r\n  \"替比夫定\": [\r\n    \"telbivudine\"\r\n  ],\r\n  \"索磷布韦\": [\r\n    \"sofosbuvir\"\r\n  ],\r\n  \"维帕他韦\": [\r\n    \"velpatasvir\"\r\n  ],\r\n  \"格卡瑞韦\": [\r\n    \"grazoprevir\"\r\n  ],\r\n  \"哌仑他韦\": [\r\n    \"pibrentasvir\"\r\n  ],\r\n  \"伏西瑞韦\": [\r\n    \"voxilaprevir\"\r\n  ],\r\n  \"艾尔巴韦\": [\r\n    \"elbasvir\"\r\n  ],\r\n  \"达拉他韦\": [\r\n    \"daclatasvir\"\r\n  ],\r\n  \"阿舒瑞韦\": [\r\n    \"asunaprevir\"\r\n  ],\r\n  \"达塞布韦\": [\r\n    \"dasabuvir\"\r\n  ],\r\n  \"波普瑞韦\": [\r\n    \"boceprevir\"\r\n  ],\r\n  \"特拉匹拉韦\": [\r\n    \"telaprevir\"\r\n  ],\r\n  \"西咪匹韦\": [\r\n    \"simeprevir\"\r\n  ],\r\n  \"帕利瑞韦\": [\r\n    \"paritaprevir\"\r\n  ],\r\n  \"奥比他韦\": [\r\n    \"ombitasvir\"\r\n  ],\r\n  \"异烟肼\": [\r\n    \"isoniazid\"\r\n  ],\r\n  \"利福平\": [\r\n    \"rifampicin\"\r\n  ],\r\n  \"吡嗪酰胺\": [\r\n    \"pyrazinamide\"\r\n  ],\r\n  \"乙胺丁醇\": [\r\n    \"ethambutol\"\r\n  ],\r\n  \"链霉素\": [\r\n    \"streptomycin\"\r\n  ],\r\n  \"对氨基水杨酸\": [\r\n    \"para-aminosalicylic acid\"\r\n  ],\r\n  \"利福布汀\": [\r\n    \"rifabutin\"\r\n  ],\r\n  \"利福喷丁\": [\r\n    \"rifapentine\"\r\n  ],\r\n  \"贝达喹啉\": [\r\n    \"bedaquiline\"\r\n  ],\r\n  \"德拉马尼\": [\r\n    \"delamanid\"\r\n  ],\r\n  \"氯法齐明\": [\r\n    \"clofazimine\"\r\n  ],\r\n  \"环丝氨酸\": [\r\n    \"cycloserine\"\r\n  ],\r\n  \"丙硫异烟胺\": [\r\n    \"protionamide\"\r\n  ],\r\n  \"氨硫脲\": [\r\n    \"thioacetazone\"\r\n  ],\r\n  \"卷曲霉素\": [\r\n    \"capreomycin\"\r\n  ],\r\n  \"卡那霉素\": [\r\n    \"kanamycin\"\r\n  ],\r\n  \"阿米卡星\": [\r\n    \"amikacin\"\r\n  ],\r\n  \"加替沙星\": [\r\n    \"gatifloxacin\"\r\n  ],\r\n  \"环丙沙星\": [\r\n    \"ciprofloxacin\"\r\n  ],\r\n  \"氧氟沙星\": [\r\n    \"ofloxacin\"\r\n  ],\r\n  \"诺氟沙星\": [\r\n    \"norfloxacin\"\r\n  ],\r\n  \"依诺沙星\": [\r\n    \"enoxacin\"\r\n  ],\r\n  \"洛美沙星\": [\r\n    \"lomefloxacin\"\r\n  ],\r\n  \"司帕沙星\": [\r\n    \"sparfloxacin\"\r\n  ],\r\n  \"培氟沙星\": [\r\n    \"pefloxacin\"\r\n  ],\r\n  \"妥舒沙星\": [\r\n    \"tosufloxacin\"\r\n  ],\r\n  \"芦氟沙星\": [\r\n    \"rufloxacin\"\r\n  ],\r\n  \"克林霉素\": [\r\n    \"clindamycin\"\r\n  ],\r\n  \"林可霉素\": [\r\n    \"lincomycin\"\r\n  ],\r\n  \"磷霉素\": [\r\n    \"fosfomycin\"\r\n  ],\r\n  \"夫西地酸\": [\r\n    \"fusidic acid\"\r\n  ],\r\n  \"利奈唑胺\": [\r\n    \"linezolid\"\r\n  ],\r\n  \"替加环素\": [\r\n    \"tigecycline\"\r\n  ],\r\n  \"替考拉宁\": [\r\n    \"teicoplanin\"\r\n  ],\r\n  \"万古霉素\": [\r\n    \"vancomycin\"\r\n  ],\r\n  \"去甲万古霉素\": [\r\n    \"norvancomycin\"\r\n  ],\r\n  \"达托霉素\": [\r\n    \"daptomycin\"\r\n  ],\r\n  \"特拉万星\": [\r\n    \"telavancin\"\r\n  ],\r\n  \"头孢洛林\": [\r\n    \"ceftaroline\"\r\n  ],\r\n  \"头孢他啶\": [\r\n    \"ceftazidime\"\r\n  ],\r\n  \"头孢哌酮\": [\r\n    \"cefoperazone\"\r\n  ],\r\n  \"头孢吡肟\": [\r\n    \"cefepime\"\r\n  ],\r\n  \"头孢噻肟\": [\r\n    \"cefotaxime\"\r\n  ],\r\n  \"头孢唑林\": [\r\n    \"cefazolin\"\r\n  ],\r\n  \"头孢拉定\": [\r\n    \"cefradine\"\r\n  ],\r\n  \"头孢克洛\": [\r\n    \"cefaclor\"\r\n  ],\r\n  \"头孢丙烯\": [\r\n    \"cefprozil\"\r\n  ],\r\n  \"头孢地尼\": [\r\n    \"cefdinir\"\r\n  ],\r\n  \"头孢克肟\": [\r\n    \"cefixime\"\r\n  ],\r\n  \"头孢布烯\": [\r\n    \"ceftibuten\"\r\n  ],\r\n  \"头孢泊肟酯\": [\r\n    \"cefpodoxime proxetil\"\r\n  ],\r\n  \"亚胺培南\": [\r\n    \"imipenem\"\r\n  ],\r\n  \"美罗培南\": [\r\n    \"meropenem\"\r\n  ],\r\n  \"厄他培南\": [\r\n    \"ertapenem\"\r\n  ],\r\n  \"比阿培南\": [\r\n    \"biapenem\"\r\n  ],\r\n  \"帕尼培南\": [\r\n    \"panipenem\"\r\n  ],\r\n  \"氨曲南\": [\r\n    \"aztreonam\"\r\n  ],\r\n  \"克拉维酸\": [\r\n    \"clavulanic acid\"\r\n  ],\r\n  \"舒巴坦\": [\r\n    \"sulbactam\"\r\n  ],\r\n  \"他唑巴坦\": [\r\n    \"tazobactam\"\r\n  ],\r\n  \"阿维巴坦\": [\r\n    \"avibactam\"\r\n  ],\r\n  \"瑞来巴坦\": [\r\n    \"relebactam\"\r\n  ],\r\n  \"法硼巴坦\": [\r\n    \"vaborbactam\"\r\n  ],\r\n  \"多尼培南\": [\r\n    \"doripenem\"\r\n  ],\r\n  \"头孢他啶阿维巴坦\": [\r\n    \"ceftazidime-avibactam\"\r\n  ],\r\n  \"美罗培南法硼巴坦\": [\r\n    \"meropenem-vaborbactam\"\r\n  ],\r\n  \"亚胺培南西司他丁\": [\r\n    \"imipenem-cilastatin\"\r\n  ],\r\n  \"头孢哌酮舒巴坦\": [\r\n    \"cefoperazone-sulbactam\"\r\n  ],\r\n  \"哌拉西林他唑巴坦\": [\r\n    \"piperacillin-tazobactam\"\r\n  ],\r\n  \"阿莫西林克拉维酸\": [\r\n    \"amoxicillin-clavulanate\"\r\n  ],\r\n  \"氟康唑\": [\r\n    \"fluconazole\"\r\n  ],\r\n  \"伊曲康唑\": [\r\n    \"itraconazole\"\r\n  ],\r\n  \"伏立康唑\": [\r\n    \"voriconazole\"\r\n  ],\r\n  \"泊沙康唑\": [\r\n    \"posaconazole\"\r\n  ],\r\n  \"卡泊芬净\": [\r\n    \"caspofungin\"\r\n  ],\r\n  \"米卡芬净\": [\r\n    \"micafungin\"\r\n  ],\r\n  \"阿尼芬净\": [\r\n    \"anidulafungin\"\r\n  ],\r\n  \"两性霉素B\": [\r\n    \"amphotericin b\"\r\n  ],\r\n  \"氟胞嘧啶\": [\r\n    \"flucytosine\"\r\n  ],\r\n  \"特比萘芬\": [\r\n    \"terbinafine\"\r\n  ],\r\n  \"酮康唑\": [\r\n    \"ketoconazole\"\r\n  ],\r\n  \"咪康唑\": [\r\n    \"miconazole\"\r\n  ],\r\n  \"克霉唑\": [\r\n    \"clotrimazole\"\r\n  ],\r\n  \"益康唑\": [\r\n    \"econazole\"\r\n  ],\r\n  \"制霉菌素\": [\r\n    \"nystatin\"\r\n  ],\r\n  \"环吡酮胺\": [\r\n    \"ciclopirox olamine\"\r\n  ],\r\n  \"阿莫罗芬\": [\r\n    \"amorolfine\"\r\n  ],\r\n  \"艾沙康唑\": [\r\n    \"isavuconazole\"\r\n  ],\r\n  \"奥希替尼\": [\r\n    \"osimertinib\"\r\n  ],\r\n  \"吉非替尼\": [\r\n    \"gefitinib\"\r\n  ],\r\n  \"厄洛替尼\": [\r\n    \"erlotinib\"\r\n  ],\r\n  \"阿法替尼\": [\r\n    \"afatinib\"\r\n  ],\r\n  \"克唑替尼\": [\r\n    \"crizotinib\"\r\n  ],\r\n  \"伊马替尼\": [\r\n    \"imatinib\"\r\n  ],\r\n  \"索拉非尼\": [\r\n    \"sorafenib\"\r\n  ],\r\n  \"帕博利珠单抗\": [\r\n    \"pembrolizumab\"\r\n  ],\r\n  \"纳武利尤单抗\": [\r\n    \"nivolumab\"\r\n  ],\r\n  \"信迪利单抗\": [\r\n    \"sintilimab\"\r\n  ],\r\n  \"卡瑞利珠单抗\": [\r\n    \"camrelizumab\"\r\n  ],\r\n  \"曲妥珠单抗\": [\r\n    \"trastuzumab\"\r\n  ],\r\n  \"贝伐珠单抗\": [\r\n    \"bevacizumab\"\r\n  ],\r\n  \"利妥昔单抗\": [\r\n    \"rituximab\"\r\n  ],\r\n  \"佐妥昔单抗\": [\r\n    \"zolbetuximab\"\r\n  ]\r\n}\n\nFile v5.8.0:references/effect_size.md\n\n# Effect Size Reference\r\n\r\n> **English:** Cohen's d f h standards for judging effect size magnitude. Cohen's d f h\r\n\r\n## Cohen's d Cohen's d\r\n\r\n|Size|d|Clinical Example|\r\n|:---------:|:--:|:-----------------------------|\r\n|Small|0.2|Blood pressure ↓ 5 mmHg|\r\n|Medium|0.5|Blood pressure ↓ 10-15 mmHg|\r\n|Large|0.8|Blood pressure ↓ >20 mmHg|\r\n\r\n## Cohen's f Cohen's f\r\n\r\n|Size|f|ANOVA Interpretation|\r\n|:---------:|:--:|:---------------------|\r\n|Small|0.10|Groups slightly different|\r\n|Medium|0.25|Clinically relevant|\r\n|Large|0.40|Clearly separated|\r\n\r\n## h Effect Size (arcsin-transformed rates) h\r\n\r\n|Size|h|arcsin Rate Difference|\r\n|:---------:|:--:|:----------------------|\r\n|Small|0.20|~0.10 (rate diff)|\r\n|Medium|0.50|~0.25 (rate diff)|\r\n|Large|0.80|~0.40 (rate diff)|\r\n\r\n## Conversion Formulas\r\n\r\n|Conversion|Formula|\r\n|:----------------|:-------------|\r\n| Cohen's d → f | $f = d/2$ |\r\n| Cohen's d → r | $r = d/\\sqrt{d^2+4}$ |\r\n| r → Cohen's d | $d = 2r/\\sqrt{1-r^2}$ |\r\n| OR → Cohen's d | $d = \\log(OR) \\times \\sqrt{3}/\\pi$ |\r\n| η² → Cohen's f | $f = \\sqrt{\\eta^2/(1-\\eta^2)}$ |\r\n\r\n## Z-Value Quick Reference Z\r\n\r\n| $\\alpha$ | One-sided $Z_{1-\\alpha}$ | Two-sided $Z_{1-\\alpha/2}$ |\r\n|:--------:|:------------------------:|:--------------------------:|\r\n| 0.10 | 1.282 | 1.645 |\r\n| 0.05 | 1.645 | 1.960 |\r\n| 0.025 | 1.960 | 2.242 |\r\n| 0.01 | 2.326 | 2.576 |\r\n| 0.001 | 3.090 | 3.291 |\r\n\r\n| $\\beta$ | $Z_{1-\\beta}$ |\r\n|:-------:|:------------:|\r\n| 0.20 | 0.842 |\r\n| 0.10 | 1.282 |\r\n| 0.05 | 1.645 |\r\n| 0.01 | 2.326 |\n\nArchive v5.6.1: 68 files, 477468 bytes\n\nFiles: adapters/__init__.py (248b), adapters/bug_report.py (20622b), adapters/coze_client.py (60454b), adapters/coze_token_embedded.py (6773b), adapters/llm_loader.py (4638b), adapters/rendering.py (41071b), AGENTS.md (11358b), assets/icon.svg (3218b), CHANGELOG.md (249461b), config/config.json (422b), config/llm_key.py (389b), docs/ADVANCED_zh-CN.md (15558b), docs/ADVANCED.md (15522b), docs/ROADMAP.md (4287b), LICENSE (1089b), README_zh-CN.md (20979b), README.md (23608b), references/adaptive_simulator.md (8690b), references/backend_optimization_2026-09-11.md (4161b), references/batch_calls.md (3504b), references/bug_report_endpoint.md (3012b), references/cli_examples.md (15248b), references/data_format_guide.md (14653b), references/default_figures.md (8702b), references/drug_name_map.json (23396b), references/effect_size.md (1541b), references/examples.md (2397b), references/extended_functions.md (21223b), references/formulas.md (4041b), references/justification_templates.md (3555b), references/language_policy.md (2658b), references/menu.md (12900b), references/operation_sop.md (6633b), references/python_usage.md (3271b), references/rendering_rules.md (4745b), references/report_template.md (3572b), references/security_model.md (3755b), references/svg_editing.md (1567b), references/term_map.json (23195b), references/units.md (3748b), requirements.txt (453b), scripts/alloc_curve.py (49147b), scripts/assumption_block.py (9551b), scripts/classify_test.py (12501b), scripts/compute_backend.py (11072b), scripts/drug_name_resolver.py (5977b), scripts/excel_style.py (24154b), scripts/figure_kit.py (56492b), scripts/hypothesis_audit.py (27411b), scripts/i18n_messages.json (38864b), scripts/i18n_r_messages.json (3035b), scripts/i18n_skill_messages.json (24214b), scripts/i18n.py (36070b), scripts/justify_text.py (16403b), scripts/keyword_breadth.py (9756b), scripts/kw_lexicon.json (32482b), scripts/kw_localize.py (35924b), scripts/merge_spec.py (3756b), scripts/mult_alloc.py (7879b), scripts/office_to_md.py (18121b), scripts/param_aliases.py (11726b), scripts/r_libs.py (8104b), scripts/samplesize_power.py (77128b), scripts/source_guard.py (5915b), scripts/verify.py (33602b), skill-card.md (2334b), SKILL.md (25712b), _meta.json (132b)\n\nFile v5.6.1:SKILL.md\n\n---\r\nslug: ct-samplesize\r\ndisplayName: Clinical Trial Sample Size / 临床试验样本量专家\r\nname: ct-samplesize\r\ncn_name: 临床试验样本量专家\r\nversion: 5.8.0\r\ninvocable: true\r\nrequired_commands: [python]\r\nsummary: 为临床试验从业者提供的样本量与检验效能计算工具。本地无需安装 R，直接提供云端 R 计算服务（覆盖 49 种检验，并提供 SVG 出版级别图形）。自然语言驱动，默认回传完整 R 代码；默认按操作系统语言设定输出中文或英文（提示词可强制切换）。\r\nlicense: MIT\r\ndescription: \"Sample size and power calculation tool for clinical trial practitioners. No local R install needed — a cloud R compute service covers all 49 test types and returns publication-grade SVG figures. Natural-language driven; full reproducible R code is returned by default; default output in Chinese or English per OS language setting (prompt can force-switch). / 为临床试验从业者提供的样本量与检验效能计算工具。本地无需安装 R，直接提供云端 R 计算服务（覆盖 49 种检验，并提供 SVG 出版级别图形）。自然语言驱动，默认回传完整 R 代码；默认按操作系统语言设定输出中文或英文（提示词可强制切换）。\"\r\ntriggers:\r\n  - \"clinical trial sample size\"\r\n  - \"样本量计算\"\r\n  - \"clinical trial power\"\r\n  - \"检验效能计算\"\r\n  - \"临床试验 设计\"\r\n  - \"non-inferiority sample size\"\r\n  - \"equivalence sample size\"\r\n  - \"survival analysis sample size\"\r\n  - \"adaptive design\"\r\n  - \"group sequential design\"\r\n  - \"Bayesian clinical trial\"\r\nmetadata: { openclaw: { emoji: \"📊\" }, authors: [\"medstatstar\", \"phoe-zip\"], license: \"MIT\", tags: [clinical-trial, sample-size, power, coze, adaptive-design, bayesian, win-ratio], homepage: \"https://github.com/medstatstar/ct-samplesize\" }\r\npermissions:\r\n  scope: \"user-space-only\"\r\n  network: \"required\"\r\n  network_note: \"v5 requires the remote coze compute endpoint (CTSS_COZE_ENDPOINT, or CTSS_COZE_MOCK=1 for a local demo) — the published skill has no local compute fallback. Only trial-design parameters leave the machine (no patient data); every request also carries a hostname hash `query_origin` (sha256, for server attribution/rate-limit) and the OS-language-derived `locale`, and the skill version `skill_version` (read from the local SKILL.md, for per-version attribution of cloud usage). Outbound authorization gate: the public endpoint is pre-whitelisted in config/config.json auto_approve_endpoints (never prompts, but the assistant states what is sent on first use); user-custom endpoints trigger a one-time AUTH-BLOCK user confirmation before any data leaves the machine. Payloads are sanitized (PII stripped) before sending.\"\r\n  filesystem: \"writes figures to CTSS_OUTPUT_DIR (default ./outputs) and optional curve PNGs; otherwise read-only\"\r\n  data: \"no patient/external data leaves the boundary — only trial-design parameters plus the hostname hash (query_origin), the skill version (skill_version) and locale metadata are sent to the coze service\"\r\n\r\n---\r\n\r\n# Clinical Trial Sample Size\r\n\r\n## Published Application\r\n\r\n| Item | Value |\r\n|---|---|\r\n| Share link | `https://ct-samplesize.app.workbuddy.host/` |\r\n| appId | `wbapp_9K1dei1PydVQ66YmawCD3C` |\r\n| domainPrefix | `ct-samplesize` |\r\n| Deploy metadata | `adapters/workbench/app.config.json` |\r\n| Deployed as | Static site (`python -m http.server $PORT --bind 0.0.0.0`) |\r\n| Payload | `WorkBuddy/2026-09-14-14-39-40/deploy_ctss/static/index.html` |\r\n\r\n> **Re-publish rule**: always overwrite with the existing `appId` — the link must stay\r\n> `https://ct-samplesize.app.workbuddy.host/`. Never `createNewApp`. After deploy, assert the returned\r\n> `shareLink` equals the expected URL (see ct-base §13.5 dirty-binding red line). Last republished\r\n> 2026-09-26 (feedback two-stage fix).\r\n\r\n## Language\r\n\r\n- **English guide** → [README.md](https://github.com/medstatstar/ct-samplesize/blob/main/README.md) · **中文指南** → [README_zh-CN.md](https://github.com/medstatstar/ct-samplesize/blob/main/README_zh-CN.md)\r\n- Bilingual auto-switch: the answer language follows the user's question language (English question → English answer, Chinese question → Chinese answer).\r\n\r\n## Purpose\r\n\r\nThis skill provides clinical trial researchers with an easy-to-use, comprehensive sample size & power calculation tool. **The default authoritative engine is a remote coze R compute service** (rpact / TrialSize / PowerTOST and 20+ other packages — running server-side, so your machine needs **no local R**), covering all 49 test types. Results come in Chinese or English per the OS language setting (prompt can force-switch). Reproducible R code is returned by default (coze returns it on every analysis).\r\n\r\n---\r\n\r\n## Features\r\n\r\n| Capability | Description | Typical Scenario |\r\n|:---|:---|:---|\r\n| **① Sample size ⇄ Power (bidirectional)** | Solve n given target power, AND solve achievable power given fixed n. `--power` (forward) and `--nobs` (reverse) are mutually exclusive; covers all 49 types. | Sample size fixed, evaluate if power meets target |\r\n| **② Power curve** | Given a sample-size sequence, batch-compute and plot the **Power curve** (x=sample size, y=power), with a target-power reference line. | Sample-size sensitivity analysis, protocol reporting |\r\n| **③ Sample-size curve** | Given a power-target sequence, batch-compute and plot the **sample-size curve** (x=target power, y=required n). | Resource planning, feasibility assessment |\r\n| **④ Deterministic NL pre-route (zero-LLM)** | `--nl \"<natural language>\"` runs a local zero-LLM deterministic detector that identifies `--test` and extracts params (power 80%→0.8, rate 70%→0.7, \"enroll 30\"→reverse-solve power, etc.), emitting a strong signal for the coze request; when confidence is low / params incomplete it prints a structured prompt and **never silently mis-params** — the local agent then asks the user for the missing test/params (≤2 rounds, then defaults); **raw NL text is never sent to coze** (the workbench is **deterministic-first** — `classify_test` + `param_aliases`, identical to conversation mode; the LLM fallback in `adapters/workbench/nl_llm.py` defaults to the family backend model LongCat-2.0 per ct-base §12 (key via `load_llm_key()`: `LONGCAT_API_KEY` env > obfuscated `config/llm_key.py`; `CTSS_NL_ENDPOINT` overrides to any OpenAI-compatible model) and may only propose a test when rules fail — never override a rule-identified test; the coze compute endpoint has no NL/LLM path). Logic in `scripts/classify_test.py` + `scripts/param_aliases.py`; per-test contract baselines in `tests/coze_cases/` (`tests/coze_cases_regression.py` offline regression), 49-test enumeration in `adapters/coze/coze_contract.md`. | User phrases it colloquially, e.g. \"non-inferiority survival trial, NI margin 1.25…\" |\r\n\r\n- ②③ curve mode: list `\"20,40,200\"` or auto-seq `\"20:20:200\"` (start:step:stop); overlay multiple effect-size curves for sensitivity (continuous/survival solvers; proportion solvers plot the single p1/p2 series); returns the figure (SVG default per the ct-* uniform figure spec, PNG fallback) **plus the numeric series as machine-readable stats (x/y arrays)**. Full parameters & 49-test examples → `references/cli_examples.md`.\r\n- **Specialized curve modes (`--effect_seq` / `--dist_plot` / `--power_time_seq` / `--heatmap`, added 2026-08-28):** effect-axis / H0–H1 overlap / follow-up-power / 2-D sensitivity scans for the 9 curve solvers; full parameters & 49-test examples → `references/cli_examples.md`.\r\n- **★ Default figures (v5.6 + 2026-08-28):** when no figure is requested, the R engine auto-attaches the full set for the 9 curve solvers (curves + dist-overlap + heatmap) and the survival follow-up–power curve (`type` field + bilingual `caption`); all figure generation moved to the coze side — coze R (`coze_figure_layer.R`) is the primary plotter, `figure_kit.py` the coze-internal fallback, the local CLI a **thin client** consuming coze-returned `figures[]`. **Zero new R packages**. Opt out via any explicit figure flag / `--dry-run`; see [Default Figures (v5.6)](#default-figures-v56) and `references/default_figures.md`.\r\n\r\n---\r\n\r\n## Interaction — Triage first\r\n\r\nBefore answering, triage the request into the four-level difficulty **Simple / Middle / Complex / Vague**:\r\n- **Simple** (test already named, params mostly given) → answer directly, **no menu**.\r\n- **Middle** (single-point but deep — ICH guidance detail, statistical parameter, compliance gray zone, needs 3–4 points) → still answer **directly, no menu** (same path as Simple; mark `difficulty = \"middle\"` for a richer multi-point answer). When Simple vs Middle is unclear, prefer **Middle**.\r\n- **Complex** (pick test type / design family / many params) → show the **routing menu** below (**the `## Quick Menu` is for the Complex branch only**).\r\n- **Vague** (\"not sure which test to use\") → **bounded grill-me** (branch-by-branch probing), do **not** dump the menu. **Hard cap: ≤3 rounds** (on reaching the cap with the test still undecided, **converge with the accumulated question profile** — pick the best-fit test family and confirm). Each round ask 1–3 focused questions with a recommended default; accumulate confirmed fields into a **question profile**; when the test is locked, **echo a \"needs portrait + recommended test + missing params\" summary for confirmation** before computing. (This 3-round cap targets locking the test; the global missing-parameter cap is **2 rounds then use defaults** — different dimensions, no conflict.)\r\n\r\n**Routing gate (audit follow-up — avoid accidental remote compute):** a **remote coze compute** (data leaves the machine) happens **only** when the user's intent is explicitly a sample-size / power / curve **calculation**. General consulting — \"help me figure out my trial design\", methodology questions, ICH guidance, \"what test should I use\" — must be answered **locally without sending anything**, and may use the menu / grill-me flow. Do not fire a coze request on vague or advisory phrasing; ask for the calculation intent first.\r\n\r\n## Cross-turn Continuity (mandatory)\r\n\r\n> **Runtime is stateless.** The coze R engine re-supplies `test`+`params` each call and never persists prior fields. Semantic drift (effect/α/power/n silently changing) = highest-risk failure for a stateless remote.\r\n\r\n**Hard rules** (full rules below (Cross-turn Continuity); minimal unit = `{test, effect, alpha, power, solve, side, sd}`, `—` = not-yet-known):\r\n1. **Echo a `## 当前分析设定：` block after every calculation (mandatory):** `## 当前分析设定： test=ttest_ind | effect(d)=0.5 | alpha=0.05 | power=0.8 | solve=n | side=two | sd=1.0 | n=— | ratio=—`. No field omitted (`—` placeholder). `solve=n` solves n given power; `solve=power` reverses; `side=two/one_greater/one_less`.\r\n2. **On follow-up, change only the changed fields:** read the most recent `## 当前分析设定：` block, override only the changed field, inherit the rest verbatim, then send to coze.\r\n3. **Deterministic merge (default path, not optional):** every follow-up **MUST run** `merge_spec.py` for a lossless merge, then send the merged spec to coze — never assemble params from LLM memory alone. `echo '{\"prev\":{...},\"cur\":{\"power\":0.9}}' | python scripts/merge_spec.py` (dev: `scripts/merge_spec.py`). If `missing_required` is non-empty, clarify first. (The `compute` payload also carries `resolved_spec`, a full snapshot — additive, landed.)\r\n\r\n> Red line: ct-samplesize's coze is a **stateless remote compute**; continuity MUST be solved locally — the remote cannot help unless you actively send history. `merge_spec.py` is the local **deterministic merger** (code-fixed, LLM-executed), not a fragile classifier — upholds family red line 4.\r\n\r\n## Batch-call governance (v5.7, must-read)\r\nMandatory constraints (curve-already-contains-single-point; batch-grid-submit; trim-envelope via `build_params`) + Feishu-backend evidence + outbound envelope guard + local `--batch-file` → `references/batch_calls.md`.\r\n\r\n## Quick Menu — two-level routing (level-1 only here; level-2 in `references/menu.md`)\r\n\r\n> Authoritative layered menu: [`references/menu.md`](references/menu.md) · CLI examples & bidirectional solve: [`references/cli_examples.md`](references/cli_examples.md) · Operation SOP: [`references/operation_sop.md`](references/operation_sop.md).\r\n>\r\n> **Two-level routing rule (per Type-Compute, do NOT dump the full test list):** on a Complex request, first show **only this level-1 summary** (6 endpoint categories + high-frequency design families). After the user picks a category, go to `references/menu.md` **Part 1** for that category and show the **level-2 sub-list** (the specific `--test` options). Never present all ~49 tests in one screen.\r\n\r\n**Level 1 — endpoint categories:**\r\n- ① **Continuous** (means) · ② **Binary / Proportions** (rates, OR/RR, NI/BE) · ③ **Count / Rates** (Poisson) · ④ **Survival / Time-to-event** (logrank, HR, one-sample) · ⑤ **Diagnostic / Method comparison** (ROC, Bland-Altman) · ⑥ **Special / Advanced designs** (group-sequential, adaptive, Bayesian, MAMS, win-ratio, cluster …)\r\n\r\n**Level 1 — high-frequency design-family entries** (non-exclusive; full list in `references/menu.md` Part 2): Group-Sequential · Adaptive · Equivalence / Non-inferiority / BE · Bayesian · Dose-escalation · MAMS · Historical control · Vaccine · Win-statistics · Cluster / Multiple endpoints\r\n\r\n> ③ **Can't decide?** → say \"explain the differences between these choices in detail\", and I'll clarify the clinical/statistical meaning before you choose. (Family-standard wording, verbatim.)\r\n\r\n> The menu is a *navigation aid*, not a strict taxonomy: the same test is reachable from multiple categories (e.g. `gsd_survival` from both ④ Survival and the Group-Sequential index). Still unsure where to start? Use **Part 0** in `references/menu.md` — find your test by *research question*, no jargon needed.\r\n\r\n**Advanced:** `--test adaptive_simulate` empirically validates adaptive / group-sequential designs (power, type I error, expected N) — full guide → [`references/adaptive_simulator.md`](references/adaptive_simulator.md). `--verify` (default OFF) re-simulates an **analytic** solution with an **independent** Monte-Carlo engine (checks empirical power ±2 pp / type-I error ±0.5 pp; takes only the n as input, so a wrongly-derived n is caught) — supports `ttest_* / proportion_two / survival(log-rank) / group_sequential / adaptive_reestimate`; reports MC 95% CI, returns `INCONCLUSIVE` rather than a false PASS. Pure local, no network. `--audit` (added 2026-09-29, planning layer) grades every design assumption **known / weak / unknown / missing** (with fabrication-signature heuristics + `--evidence-source` promotion), maps the test into 7 design-logic families with self-consistency checks, and emits **fallback/contingency plans** per weakest assumption; exits without computing; complements (not replaces) `--show-assumptions`. Pure local (`scripts/hypothesis_audit.py`). `--mcid Δ --sd S [--mcid-source …]` (J1) is a clinically-worded alias of the Δ/sd conversion channel (d = MCID/SD, echo + audit linkage); `--justify` (J2) appends an **IRB/SAP-ready bilingual justification paragraph** — hidden by default: the paragraph text renders software as `R <ver> + rpact/TrialSize <ver>` (versions from the result envelope; no cloud/local wording; unknown versions render as fill-in placeholders), and after a successful single computation the CLI prints a one-line offer — **when you see that offer, ask the user whether they want the document paragraph; generate it only on their yes (re-run with `--justify`)**. Skeleton = CONSORT-SPIRIT Item14/DELTA2 Box4 + CDE《样本量估计指导原则(试行)》2024-12-23; placeholders must be filled by the investigator — anti fake-precision. Details → [`references/justification_templates.md`](references/justification_templates.md). Pure local (`scripts/justify_text.py`).\r\n\r\n---\r\n\r\n## Requirements\r\n\r\n| Requirement\n\nArchive v5.6.0: 51 files, 322753 bytes\n\nFiles: adapters/__init__.py (248b), adapters/bug_report.py (20622b), adapters/coze_client.py (40471b), adapters/coze_token_embedded.py (6773b), adapters/rendering.py (40615b), AGENTS.md (11403b), assets/icon.svg (3218b), CHANGELOG.md (162369b), config/config.json (422b), docs/ADVANCED_zh-CN.md (15558b), docs/ADVANCED.md (15522b), docs/ROADMAP.md (4287b), LICENSE (1089b), README_zh-CN.md (20711b), README.md (23279b), references/adaptive_simulator.md (8690b), references/bug_report_endpoint.md (3012b), references/cli_examples.md (15248b), references/data_format_guide.md (14653b), references/default_figures.md (7136b), references/effect_size.md (1541b), references/examples.md (2285b), references/extended_functions.md (21223b), references/formulas.md (4041b), references/language_policy.md (2704b), references/menu.md (13008b), references/operation_sop.md (6633b), references/python_usage.md (3271b), references/rendering_rules.md (4818b), references/report_template.md (3572b), references/security_model.md (3765b), references/svg_editing.md (1540b), references/units.md (3748b), requirements.txt (453b), scripts/alloc_curve.py (49147b), scripts/assumption_block.py (9551b), scripts/classify_test.py (11212b), scripts/compute_backend.py (9812b), scripts/figure_kit.py (56492b), scripts/i18n_messages.json (31651b), scripts/i18n_r_messages.json (3035b), scripts/i18n_skill_messages.json (24214b), scripts/i18n.py (7364b), scripts/mult_alloc.py (7879b), scripts/office_to_md.py (7571b), scripts/param_aliases.py (9926b), scripts/samplesize_power.py (62709b), scripts/verify.py (33602b), skill-card.md (2937b), SKILL.md (23981b), _meta.json (132b)\n\nArchive v5.3.14: 63 files, 263998 bytes\n\nFiles: adapters/__init__.py (248b), adapters/bug_report.py (20622b), adapters/coze_client.py (39619b), adapters/coze_token_embedded.py (6773b), adapters/rendering.py (40344b), ADVANCED_zh-CN.md (15558b), ADVANCED.md (15522b), AGENTS.md (11393b), assets/icon.svg (3218b), CHANGELOG.md (129873b), config/config.json (422b), coze_cases/_contract_index.json (19804b), coze_cases/cases/adaptive_simulate.json (581b), coze_cases/cases/bayesian.json (413b), coze_cases/cases/be_tost.json (412b), coze_cases/cases/cluster.json (399b), coze_cases/cases/conditional_power.json (601b), coze_cases/cases/group_sequential.json (470b), coze_cases/cases/gsd_proportion.json (572b), coze_cases/cases/ni_survival.json (597b), coze_cases/cases/non_inferiority.json (431b), coze_cases/cases/proportion_two_nl.json (532b), coze_cases/cases/proportion_two.json (392b), coze_cases/cases/roc.json (355b), coze_cases/cases/survival.json (360b), coze_cases/cases/ttest_ind_n.json (397b), coze_cases/cases/ttest_ind_reverse.json (368b), coze_cases/cases/vaccine_efficacy.json (420b), coze_cases/gen_cases.py (6640b), coze_cases/gen_contract_doc.py (4405b), README_zh-CN.md (20535b), README.md (23238b), references/adaptive_simulator.md (8665b), references/bug_report_endpoint.md (3012b), references/cli_examples.md (15238b), references/data_format_guide.md (14653b), references/effect_size.md (1541b), references/examples.md (2285b), references/extended_functions.md (21223b), references/formulas.md (4041b), references/language_policy.md (2704b), references/menu.md (13008b), references/operation_sop.md (6603b), references/python_usage.md (3271b), references/rendering_rules.md (3940b), references/report_template.md (3572b), references/security_model.md (3745b), references/svg_editing.md (1540b), references/units.md (3738b), requirements.txt (453b), ROADMAP.md (4287b), scripts/classify_test.py (11212b), scripts/compute_backend.py (9477b), scripts/i18n_messages.json (31651b), scripts/i18n_r_messages.json (3035b), scripts/i18n_skill_messages.json (24214b), scripts/i18n.py (7364b), scripts/office_to_md.py (7571b), scripts/param_aliases.py (9926b), scripts/samplesize_power.py (52345b), skill-card.md (3053b), SKILL.md (23004b), _meta.json (133b)\n\nArchive v5.3.12: 63 files, 262153 bytes\n\nFiles: adapters/__init__.py (248b), adapters/bug_report.py (20622b), adapters/coze_client.py (39578b), adapters/coze_token_embedded.py (6773b), adapters/rendering.py (40344b), ADVANCED_zh-CN.md (15558b), ADVANCED.md (15522b), AGENTS.md (11393b), assets/icon.svg (3218b), CHANGELOG.md (124381b), config/config.json (422b), coze_cases/_contract_index.json (19804b), coze_cases/cases/adaptive_simulate.json (581b), coze_cases/cases/bayesian.json (413b), coze_cases/cases/be_tost.json (412b), coze_cases/cases/cluster.json (399b), coze_cases/cases/conditional_power.json (601b), coze_cases/cases/group_sequential.json (470b), coze_cases/cases/gsd_proportion.json (572b), coze_cases/cases/ni_survival.json (597b), coze_cases/cases/non_inferiority.json (431b), coze_cases/cases/proportion_two_nl.json (532b), coze_cases/cases/proportion_two.json (392b), coze_cases/cases/roc.json (355b), coze_cases/cases/survival.json (360b), coze_cases/cases/ttest_ind_n.json (397b), coze_cases/cases/ttest_ind_reverse.json (368b), coze_cases/cases/vaccine_efficacy.json (420b), coze_cases/gen_cases.py (6640b), coze_cases/gen_contract_doc.py (4405b), README_zh-CN.md (20535b), README.md (23238b), references/adaptive_simulator.md (8665b), references/bug_report_endpoint.md (3012b), references/cli_examples.md (15238b), references/data_format_guide.md (14653b), references/effect_size.md (1541b), references/examples.md (2285b), references/extended_functions.md (21223b), references/formulas.md (4041b), references/language_policy.md (2704b), references/menu.md (13008b), references/operation_sop.md (6603b), references/python_usage.md (3271b), references/rendering_rules.md (3940b), references/report_template.md (3572b), references/security_model.md (3745b), references/svg_editing.md (1540b), references/units.md (3738b), requirements.txt (453b), ROADMAP.md (4287b), scripts/classify_test.py (11212b), scripts/compute_backend.py (9477b), scripts/i18n_messages.json (31651b), scripts/i18n_r_messages.json (3035b), scripts/i18n_skill_messages.json (24214b), scripts/i18n.py (7364b), scripts/office_to_md.py (7571b), scripts/param_aliases.py (9926b), scripts/samplesize_power.py (52345b), skill-card.md (3031b), SKILL.md (23004b), _meta.json (133b)\n\nArchive v5.1.0: 38 files, 185244 bytes\n\nFiles: adapters/__init__.py (242b), adapters/bug_report.py (20266b), adapters/coze_client.py (18902b), adapters/coze_token_embedded.py (6635b), adapters/rendering.py (12026b), ADVANCED_zh-CN.md (15333b), ADVANCED.md (15288b), AGENTS.md (11255b), assets/icon.svg (3218b), CHANGELOG.md (92851b), config/config.json (415b), README_zh-CN.md (16599b), README.md (18865b), references/adaptive_simulator.md (8500b), references/cli_examples.md (13013b), reference...","readmeExcerpt":"Skill: Clinical Trial Sample Size & Power / 临床试验样本量与检验效能专家 Owner: medstatstar Summary: Sample size and power calculation tool for clinical trial practitioners. No local R install needed — a cloud R compute service covers all 49 test types and returns publication-grade SVG figures. Natural-language driven; full reproducible R code is returned by default; default output in Chinese or English per OS language setting (pr","codeSnippets":[],"executableExamples":[],"parameters":null,"dependencies":[],"permissions":[],"extractedFiles":[{"path":"SKILL.md","content":"---\r\nslug: ct-samplesize\r\ndisplayName: Clinical Trial Sample Size / 临床试验样本量专家\r\nname: ct-samplesize\r\ncn_name: 临床试验样本量专家\r\nversion: 5.8.0\r\ninvocable: true\r\nrequired_commands: [python]\r\nsummary: 为临床试验从业者提供的样本量与检验效能计算工具。本地无需安装 R，直接提供云端 R 计算服务（覆盖 49 种检验，并提供 SVG 出版级别图形）。自然语言驱动，默认回传完整 R 代码；默认按操作系统语言设定输出中文或英文（提示词可强制切换）。\r\nlicense: MIT\r\ndescription: \"Sample size and power calculation tool for clinical trial practitioners. No local R install needed — a cloud R compute service covers all 49 test types and returns publication-grade SVG figures. Natural-language driven; full reproducible R code is returned by default; default output in Chinese or English per OS language setting (prompt can force-switch). / 为临床试验从业者提供的样本量与检验效能计算工具。本地无需安装 R，直接提供云端 R 计算服务（覆盖 49 种检验，并提供 SVG 出版级别图形）。自然语言驱动，默认回传完整 R 代码；默认按操作系统语言设定输出中文或英文（提示词可强制切换）。\"\r\ntriggers:\r\n  - \"clinical trial sample size\"\r\n  - \"样本量计算\"\r\n  - \"clinical trial power\"\r\n  - \"检验效能计算\"\r\n  - \"临床试验 设计\"\r\n  - \"non-inferiority sample size\"\r\n  - \"equivalence sample size\"\r\n  - \"survival analysis sample size\"\r\n  - \"adaptive design\"\r\n  - \"group sequential design\"\r\n  - \"Bayesian clinical trial\"\r\nmetadata: { openclaw: { emoji: \"📊\" }, authors: [\"medstatstar\", \"phoe-zip\"], license: \"MIT\", tags: [clinical-trial, sample-size, power, coze, adaptive-design, bayesian, win-ratio], homepage: \"https://github.com/medstatstar/ct-samplesize\" }\r\npermissions:\r\n  scope: \"user-space-only\"\r\n  network: \"required\"\r\n  network_note: \"v5 requires the remote coze compute endpoint (CTSS_COZE_ENDPOINT, or CTSS_COZE_MOCK=1 for a local demo) — the published skill has no local compute fallback. Only trial-design parameters leave the machine (no patient data); every request also carries a hostname hash `query_origin` (sha256, for server attribution/rate-limit) and the OS-language-derived `locale`, and the skill version `skill_version` (read from the local SKILL.md, for per-version attribution of cloud usage). Outbound authorization gate: the public endpoint is pre-whitelisted in config/config.json auto_approve_endpoints (never prompts, but the assistant states what is sent on first use); user-custom endpoints trigger a one-time AUTH-BLOCK user confirmation before any data leaves the machine. Payloads are sanitized (PII stripped) before sending.\"\r\n  filesystem: \"writes figures to CTSS_OUTPUT_DIR (default ./outputs) and optional curve PNGs; otherwise read-only\"\r\n  data: \"no patient/external data leaves the boundary — only trial-design parameters plus the hostname hash (query_origin), the skill version (skill_version) and locale metadata are sent to the coze service\"\r\n\r\n---\r\n\r\n# Clinical Trial Sample Size\r\n\r\n## Published Application\r\n\r\n| Item | Value |\r\n|---|---|\r\n| Share link | `https://ct-samplesize.app.workbuddy.host/` |\r\n| appId | `wbapp_9K1dei1PydVQ66YmawCD3C` |\r\n| domainPrefix | `ct-samplesize` |\r\n| Deploy metadata | `adapters/workbench/app.config.json` |\r\n| Deployed as | Static site (`python -m http.server $PORT --bind 0.0.0.0`) |\r\n| Payload | `WorkBuddy/20"},{"path":"README.md","content":"# Clinical Trial Sample Size (ct-samplesize)\r\n\r\n- **English guide** → [README.md](https://github.com/medstatstar/ct-samplesize/blob/main/README.md) · **中文指南** → [README_zh-CN.md](https://github.com/medstatstar/ct-samplesize/blob/main/README_zh-CN.md)\r\n\r\n<div align=\"center\">\r\n  <img src=\"assets/icon.svg\" alt=\"ct-samplesize logo\" width=\"240\" height=\"240\">\r\n</div>\r\n\r\n> **Works without installation:** If you'd rather not install and just want to quickly use this skill's basic features, you can also visit the ct-series unified web portal **https://ct.medstatstar.com** directly.\r\n\r\n> **Easy-to-use Clinical Sample Size & Power Calculator for Clinical Researchers**\r\n>\r\n> You don't need to code or memorize commands — just describe your trial design in **plain language inside a chat**, and the skill performs **49** professional sample-size & power calculations for you. The default authoritative engine is a **remote coze R compute service** (rpact, TrialSize, PowerTOST and 20+ other packages running server-side, so your machine needs **no local R**; the published skill has **no local compute fallback**). Results come in Chinese or English per your OS setting (force-switchable via prompt). By default the skill shows a **SAFE PREVIEW** of the exact request it would send to coze — nothing leaves your machine until you confirm; full R code can be returned on request.\r\n\r\n---\r\n\r\n## Who This Is For\r\n\r\nThe `ct-*` clinical-trial skill family covers the whole clinical-trial lifecycle. ct-samplesize targets three groups who need **defensible sample-size / power numbers across 49 designs**:\r\n\r\n- **Clinical-trial practitioners at pharmaceutical companies** — sponsors, CROs, and medical / statistical / regulatory roles: quick, auditable n / power for protocols, SAPs, feasibility.\r\n- **Clinicians and nurses who design or run trials**: estimate sample size when drafting protocols or feasibility assessments.\r\n- **Medical students who want to learn clinical-trial methodology**: exploring design families (group-sequential, adaptive, Bayesian, non-inferiority…).\r\n\r\nThis tool only takes aggregate design parameters — never patient-level data.\r\n\r\n---\r\n\r\n## 1. How to Use It in a Chat (the Core)\r\n\r\nct-samplesize is a **conversational skill**: you simply tell the assistant your trial design in natural language — no commands, no parameter names to remember. As a WorkBuddy skill it **auto-loads with no extra installation**.\r\n\r\nBelow are 6 real conversational examples ordered by common entry point — from \"not sure which test\" to specific designs. Each gives **\"You say\"** (a copy-ready natural-language input), a sketch of **\"The assistant replies\"**, plus how to get the actual number.\r\n\r\n### Example 1 · Not sure which test (most common opening)\r\n**You say:**\r\n> I want a sample-size calculation but I'm not sure which test to use — help me choose the right one\r\n\r\n**Assistant replies (sketch):**\r\n> Sure — let's pin down your trial design first. I'll ask 1–3 focused questions per round, eac"},{"path":"_meta.json","content":"{\n  \"ownerId\": \"kn7amqq1jv28skb63wavr6shah89jsm5\",\n  \"slug\": \"ct-samplesize\",\n  \"version\": \"5.8.0\",\n  \"publishedAt\": 1791547853622\n}"},{"path":"references/adaptive_simulator.md","content":"# Adaptive-Trial Monte-Carlo Simulator\r\n\r\nModule: `--test adaptive_simulate` in the main CLI. **In the published skill, the\r\nauthoritative engine is an inlined pure base-R function library** `ADAPTIVE_SIM_R`,\r\nmaintained in `adapters/coze/ct_r_lib/local_r_backend.py` (no extra R packages), running **server-side\r\non coze**. The CLI shows the coze request envelope in SAFE PREVIEW and computes via\r\ncoze (no local R/shell). **Dev / offline:** the equivalent local-R path writes the\r\ninlined engine to a temp `.R` file, `source()`s it and calls `run_adaptive_sim()`\r\n(SAFE PREVIEW, `--yes` to run). A legacy pure-Python module\r\n`adapters/coze/ct_r_lib/legacy/adaptive_simulator.py` is retained for offline dev/testing.\r\nPorted from the ClawHub skill `adaptive-trial-simulator` (aipoch-ai) and\r\nre-implemented to fit ct-samplesize.\r\n\r\n> **No standalone `.R` file is shipped in the published skill.** The R engine lives\r\n> inline in `adapters/coze/ct_r_lib/local_r_backend.py` as `ADAPTIVE_SIM_R` (excluded from the publish\r\n> package; synced to coze). To drive the engine from R yourself, run the CLI with\r\n> `--show-code` (or `-y`) and copy the printed R code into R.\r\n\r\n## Run the R engine via CLI\r\n\r\nThis is the normal path (no manual `source()` needed):\r\n\r\n```bash\r\n# default = SAFE PREVIEW (shows the generated R code that sources the inlined engine)\r\npython scripts/samplesize_power.py --test adaptive_simulate --sim_design group_sequential   --effect_size 0.3 --sim_n 200 --interim_looks 3 --spending_function obrien_fleming   --alpha 0.025 --n_simulations 20000 --sim_seed 42\r\n\r\n# add -y / --yes to execute and compute power / type I error\r\npython scripts/samplesize_power.py --test adaptive_simulate --sim_design group_sequential   --effect_size 0.3 --sim_n 200 --interim_looks 3 --spending_function obrien_fleming   --alpha 0.025 --n_simulations 20000 --sim_seed 42 -y\r\n```\r\n\r\n## Drive the engine directly from R\r\n\r\nThere is no standalone `.R` file to `source()`. To run the engine from R,\r\nreplicate what the CLI does: run `python scripts/samplesize_power.py --test\r\nadaptive_simulate ... --show-code`, copy the printed R code (it contains the full\r\n`ADAPTIVE_SIM_R` definition plus the `run_adaptive_sim(...)` call) into R, and run\r\nit. The pasted code is self-contained — base R only, no extra packages.\r\n\r\n## When to use\r\n\r\nUse this **simulation** engine when you want to *validate* an adaptive or\r\ngroup-sequential design by Monte-Carlo (empirical power, empirical type I error,\r\nexpected sample size, early-stop probabilities) rather than solve a closed-form\r\nsample size. For **analytic** group-sequential / adaptive sample size (rpact /\r\ngsDesign), use `--test group_sequential` or `--test adaptive` instead — they are\r\ncomplementary.\r\n\r\n> **coze is the primary compute path** in the published skill: the CLI shows the\r\n> coze request envelope (SAFE PREVIEW) and computes via coze (server-side R, base R\r\n> only, no extra packages). The optional local-R dev backend (`adapters/coze/ct"},{"path":"references/backend_optimization_2026-09-11.md","content":"# 后端优化建议（基于 2026-09-11 后端日志分析）\r\n\r\n> 来源：`CTDB_searchlog (3).xlsx`（26 条有效请求 / 199 行，11 分钟窗口，单会话，\r\n> skill_version 5.7.26，全部 `proportion_two`，status 全 ok）。\r\n> 本文档为**服务端（coze 部署侧）**改进项，客户端 v5.7.27 已落地守卫（见 CHANGELOG）；\r\n> 服务端改动需按既有节奏人工打包上传 Coze，客户端无依赖、可先发布。\r\n\r\n## 日志核心发现（服务端视角）\r\n\r\n| # | 发现 | 量化 | 影响 |\r\n|:--|:---|:---|:---|\r\n| 1 | 「单点+曲线」成对串行 | 13 单点 : 13 曲线（1:1） | ~50% 请求、~40s 计算可省（客户端 v5.7.27 已强化约束 + 守卫） |\r\n| 2 | 参数包过肥 | 135 参数/条（2.8KB），仅 6 个被消费 | 飞书日志全参数扫描假象；缓存签名噪声化 |\r\n| 3 | 同网格曲线重复计算 | `0.6:0.05:0.95` 8 点网格重复 5 次（38% 曲线请求） | TTL 缓存因参数微调脱靶 |\r\n| 4 | 日志空白行 | 173/199 行（87%）六字段全空 | 日志分析被脏数据污染 |\r\n\r\n## 服务端改进项\r\n\r\n### A. 同网格近似参数模糊缓存（命中 38% 曲线请求）\r\n\r\n现状：`state.py` / samplesize 节点对 `(test, params, mode, locale)` 全量归一化后做 10 分钟 TTL\r\n幂等缓存，`params` 中任一键变化（哪怕仅 `dropout_rate` 0→0.1）即脱靶。\r\n\r\n建议（按侵入性从低到高，三选一）：\r\n\r\n1. **签名前先「归一化裁剪」**：缓存签名计算前，把 `params` 按该 test 的 contract 白名单\r\n   （`required` ∪ 通用键 ∪ curve_*）裁剪——客户端 v5.7.27 守卫已在出站侧做了同样的裁剪，\r\n   两端对齐后，即使老版本客户端发来过肥信封，服务端签名也只含有效键。改动点：\r\n   签名计算函数处加一层 per-test 白名单过滤（白名单可内嵌或复用 `_contract_index.json` 的镜像）。\r\n2. **网格级缓存**：对 `curve_*_seq` 请求，签名只取 `(test, mode, 网格串, 网格消费参数集)`\r\n   （如 proportion_two 的曲线仅消费 p1/p2/alpha/side/ratio），其余键不进签名；命中后直接\r\n   复用 R 结果。适合网格重复率高的场景（本日志 38%）。\r\n3. **批量多场景接口**：扩展 batch 协议支持「同网格 + 多组参数」一次提交（batch 内逐项\r\n   独立缓存签名），配合客户端 `build_batch` 已有能力，把 5 次同网格请求压成 1 次。\r\n\r\n推荐 ①（改动最小、与客户端守卫天然对齐），②③ 视上线后日志再评估。\r\n\r\n### B. 飞书日志空白行修复（87% 脏数据）\r\n\r\n现象：199 行中 173 行 `ID/inittime/query_origin/skillname/querystr/resultstr` 六字段全空\r\n（连 ID 都没有），非正常预分配形态。\r\n\r\n排查方向：\r\n\r\n1. **写入侧**：`src/graphs/nodes/feishu_write_node.py` / `feishu_save_node.py`——检查是否存在\r\n   异常分支「先建行、后填字段」，异常时行已建但字段未写（本日志窗口 status 全 ok，\r\n   更可能是预分配/重试路径泄漏）；\r\n2. **导出侧**：若飞书多维表格模板预留下了大量空行，导出脚本未过滤 `query_origin == null`\r\n   的行——最低成本修复是在导出端过滤空行，同时排查写入端是否确有泄漏路径；\r\n3. **建议加写入侧断言**：写行前校验 `querystr` 非空，空则跳过并计数上报（避免静默膨胀）。\r\n\r\n### C.（可选）skill_version 缺失兜底\r\n\r\n客户端 `_skill_version()` 正则在 v5.7.26 及以前**全部损坏**（从未从 SKILL.md 读到过版本），\r\n历史日志中的 `skill_version` 全部来自 fallback 常量，**升版归因可能静默漂移**。\r\n服务端无需改动（客户端 v5.7.27 已修），但做日志归因分析时请注意 5.7.26 及以前的\r\n版本号可信度有限。\r\n\r\n## 部署顺序\r\n\r\n1. 客户端 v5.7.27 先发（守卫 + 正则修复，全离线验证通过，无服务端依赖）；\r\n2. 服务端 A① / B 随下一次 coze 打包部署一并上线；\r\n3. 上线后取一段新日志复测：请求参数键数（期望 ~10-20）、缓存命中率、空白行占比。"}],"languages":[],"docsSourceLabel":"CLAWHUB","editorialOverview":null,"editorialQuality":{"score":100,"threshold":65,"status":"thin","wordCount":2079,"uniquenessScore":43,"reasons":["uniqueness-below-45"]}},"media":{"evidence":{"source":"no-media","verified":false,"confidence":"low","updatedAt":"2026-10-09T18:17:45.160Z","emptyReason":"No screenshots, media assets, or demo links are available."},"primaryImageUrl":null,"mediaAssetCount":0,"assets":[],"demoUrl":null},"ownerResources":{"evidence":{"source":"unclaimed","verified":false,"confidence":"low","updatedAt":"2026-10-09T18:17:45.160Z","emptyReason":"This page has not been claimed by the agent owner."},"hasCustomPage":false,"customPageUpdatedAt":null,"customLinks":[],"structuredLinks":{"docsUrl":null,"demoUrl":null,"supportUrl":null,"pricingUrl":null,"statusUrl":null},"customPage":null},"relatedAgents":{"evidence":{"source":"protocol-neighbors","verified":false,"confidence":"medium","updatedAt":"2026-10-10T06:43:02.813Z","emptyReason":null},"items":[{"id":"8ebccd8e-3863-4187-8355-c3f14e1f9edf","entityType":"agent","canonicalPath":"/agent/iofficeai-aionui","slug":"iofficeai-aionui","name":"AionUi","description":"Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!","url":"https://github.com/iOfficeAI/AionUi","homepage":"https://www.aionui.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-10-09T19:11:12.944Z","createdAt":"2026-02-25T03:38:16.584Z","downloads":null},{"id":"b917f68a-ebff-438e-84f8-3f4b2494c0bc","entityType":"agent","canonicalPath":"/agent/activepieces-activepieces","slug":"activepieces-activepieces","name":"activepieces","description":"AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents","url":"https://github.com/activepieces/activepieces","homepage":"https://www.activepieces.com","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-15T02:22:12.426Z","createdAt":"2026-02-25T03:38:12.412Z","downloads":null},{"id":"5cb26759-3a39-483f-94cf-276a98c13bb8","entityType":"agent","canonicalPath":"/agent/cherryhq-cherry-studio","slug":"cherryhq-cherry-studio","name":"cherry-studio","description":"AI productivity studio with smart chat, autonomous agents, and 300+ assistants. Unified access to frontier LLMs","url":"https://github.com/CherryHQ/cherry-studio","homepage":"https://cherry-ai.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-11T14:38:40.986Z","createdAt":"2026-02-25T03:38:19.379Z","downloads":null},{"id":"6f6582d0-5d76-4f0f-b81d-86520247950b","entityType":"agent","canonicalPath":"/agent/copilotkit-copilotkit","slug":"copilotkit-copilotkit","name":"CopilotKit","description":"The Frontend for Agents & Generative UI. React + Angular","url":"https://github.com/CopilotKit/CopilotKit","homepage":"https://docs.copilotkit.ai","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-03-25T09:50:57.846Z","createdAt":"2026-02-25T03:39:14.617Z","downloads":null}],"links":{"hub":"/agent","source":"/agent/source/clawhub","protocols":[{"label":"OpenClaw","href":"/agent/protocol/openclew"}]}}}