bugx-cli 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +26 -29
  2. package/core/README.md +5 -3
  3. package/core/agent/agent_orchestrator.py +3 -0
  4. package/core/agent/agent_workspace.py +14 -2
  5. package/core/assets/bugx-wechat-group.png +0 -0
  6. package/core/assets/twitter_promo_art.jpg +0 -0
  7. package/core/assets/twitter_promo_card.svg +166 -0
  8. package/core/assets/twitter_promo_clean.jpg +0 -0
  9. package/core/assets/twitter_terminal_real.png +0 -0
  10. package/core/bugx.md +3 -3
  11. package/core/bugx_paths.py +10 -2
  12. package/core/bundled_docs/OVERVIEW.md +310 -0
  13. package/core/bundled_docs/README.md +10 -0
  14. package/core/bundled_docs/README_EN.md +278 -0
  15. package/core/bundled_docs/ai/01_AI_REFERENCE.md +833 -0
  16. package/core/bundled_docs/ai/02_AI_USAGE.md +161 -0
  17. package/core/bundled_docs/ai/03_AI_COMMANDS.md +322 -0
  18. package/core/bundled_docs/guides/01_USER_GUIDE.md +887 -0
  19. package/core/bundled_docs/guides/02_COMMANDS.md +935 -0
  20. package/core/bundled_docs/guides/03_TROUBLESHOOTING.md +763 -0
  21. package/core/bundled_docs/guides/04_CLOUD_AUTH_AND_SYNC_COOKBOOK.md +48 -0
  22. package/core/bundled_docs/guides/05_HOST_MATRIX_AND_DISPATCH.md +23 -0
  23. package/core/bundled_docs/guides/06_PROBES_AND_POC_COOKBOOK.md +49 -0
  24. package/core/bundled_docs/guides/07_LIFECYCLE_AND_RECOVERY_STATES.md +46 -0
  25. package/core/bundled_docs/guides/08_LESSONS_AND_PRIVACY_BOUNDARY.md +35 -0
  26. package/core/bundled_docs/hosts/bugx-claude_SKILL.md +326 -0
  27. package/core/bundled_docs/hosts/bugx-dsh_SKILL.md +229 -0
  28. package/core/bundled_docs/hosts/bugx-opencode_SKILL.md +129 -0
  29. package/core/bundled_docs/hosts/bugx-zcode_SKILL.md +459 -0
  30. package/core/bundled_docs/hosts/bugx_SKILL.md +118 -0
  31. package/core/bundled_docs/hosts/cline_bugx_SKILL.md +69 -0
  32. package/core/bundled_docs/hosts/platform_bugx_SKILL.md +50 -0
  33. package/core/bundled_docs/manifest.json +140 -0
  34. package/core/bundled_docs/reference/01_ENVIRONMENT_VARIABLES.md +421 -0
  35. package/core/bundled_docs/reference/04_REPOSITORY_TOPOLOGY.md +180 -0
  36. package/core/cli-help.txt +7 -3
  37. package/core/cloud_sync/cloud_client.py +81 -2
  38. package/core/cloud_sync/endpoint_router.py +22 -9
  39. package/core/cloud_sync/issue_uploader.py +297 -0
  40. package/core/cloud_sync/sensitive_filter.py +77 -7
  41. package/core/contracts/AGENT_GUIDE.md +3 -9
  42. package/core/contracts/README.md +1 -1
  43. package/core/contracts/bugx-opencode.md +1 -1
  44. package/core/contracts/bugx-runtime-contract.md +10 -20
  45. package/core/contracts/bugx-worker.md +1 -1
  46. package/core/engine-integrity.json +267 -111
  47. package/core/host_acp/antigravity.py +153 -0
  48. package/core/host_acp/kimi.py +175 -0
  49. package/core/host_acp/minimax.py +28 -0
  50. package/core/host_runtime/adapters.py +5 -1
  51. package/core/host_runtime/antigravity.py +162 -0
  52. package/core/host_runtime/host_bootstrap.py +18 -7
  53. package/core/host_runtime/host_evaluators.py +4 -4
  54. package/core/host_runtime/host_registry.py +25 -4
  55. package/core/host_runtime/mcp_process_tracker.py +30 -3
  56. package/core/host_runtime/mcp_registry_gate.py +34 -11
  57. package/core/hosts/antigravity.py +115 -0
  58. package/core/hosts/codex.py +3 -0
  59. package/core/hosts/dsh.py +43 -24
  60. package/core/hosts/kimi.py +293 -0
  61. package/core/hosts/minimax.py +249 -0
  62. package/core/hosts/zcode.py +5 -0
  63. package/core/i18n.py +94 -5
  64. package/core/infra/README.md +1 -1
  65. package/core/infra/build_info.py +30 -5
  66. package/core/launch_phases/README.md +2 -2
  67. package/core/launch_phases/startup_version_gate.py +2 -2
  68. package/core/launch_phases/supervisor_bridge.py +16 -23
  69. package/core/launch_phases/supervisor_degraded.py +7 -5
  70. package/core/ledger/README.md +1 -1
  71. package/core/locales/en-US.json +3 -3
  72. package/core/locales/zh-CN.json +3 -3
  73. package/core/mcp_runtime_support/environment.py +6 -1
  74. package/core/metadata.txt +2 -2
  75. package/core/planning/README.md +1 -1
  76. package/core/planning/prompt_harness.py +2 -2
  77. package/core/probes/codebase_memory_probe.py +43 -24
  78. package/core/probes/probe_registry.py +10 -7
  79. package/core/prompts/command_routing_en.md +6 -5
  80. package/core/prompts/command_routing_zh.md +6 -5
  81. package/core/repair/rsi_rounds.py +3 -0
  82. package/core/repair/self_heal.py +160 -6
  83. package/core/retrieval/README.md +1 -1
  84. package/core/runtime/README.md +1 -1
  85. package/core/runtime/scenario_eval.py +5 -1
  86. package/core/runtime/setup_ui_env.py +4 -7
  87. package/core/runtime/tool_install_targets.py +12 -2
  88. package/core/skills/README.md +4 -2
  89. package/core/skills/bugx_docs_cloud_sync.py +658 -0
  90. package/core/skills/bugx_docs_mcp_server.py +966 -140
  91. package/core/supervisor/README.md +1 -1
  92. package/core/supervisor/cli.py +2 -2
  93. package/core/supervisor/worker_execution.py +16 -3
  94. package/core/webui/docs_session_service.py +40 -2
  95. package/core/webui/mcp_inspector.py +12 -6
  96. package/core/webui/static/index.html +51 -3
  97. package/core/webui/static/manifest.webmanifest +1 -1
  98. package/core/webui/static/project-settings.js +18 -3
  99. package/core/webui/static/robots.txt +36 -0
  100. package/core/webui/static/sitemap.xml +15 -0
  101. package/docs/07_distribution/01_README_NPM.md +26 -29
  102. package/ecosystem/integrations/cline/skills/bugx/SKILL.md +46 -46
  103. package/ecosystem/integrations/dsh/agents/bugx.md +2 -1
  104. package/ecosystem/integrations/dsh/dsh-patch.yml +2 -2
  105. package/ecosystem/integrations/dsh/mcp/package.json +1 -1
  106. package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +6 -6
  107. package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +1 -1
  108. package/ecosystem/integrations/dsh/ui/package.json +1 -1
  109. package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +2 -2
  110. package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
  111. package/ecosystem/integrations/pi/skills/bugx/SKILL.md +6 -6
  112. package/ecosystem/integrations/qoder/CONNECTORS.md +11 -23
  113. package/ecosystem/integrations/qoder/connector-meta.json +9 -9
  114. package/ecosystem/integrations/workbuddy/connector-meta.json +9 -9
  115. package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +8 -7
  116. package/ecosystem/plugins/bugx/.claude-plugin/marketplace.json +2 -2
  117. package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +2 -2
  118. package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +4 -4
  119. package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +2 -2
  120. package/ecosystem/plugins/bugx/agents/bugx-worker.md +14 -18
  121. package/ecosystem/plugins/bugx/agents/bugx.md +45 -49
  122. package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +8 -8
  123. package/ecosystem/plugins/bugx/skills/bugx-claude/SKILL.md +1 -1
  124. package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +1 -1
  125. package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +1 -1
  126. package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +3 -3
  127. package/interfaces/bin/bugx.js +2 -0
  128. package/interfaces/cli/bugx_cli/__init__.py +2 -2
  129. package/interfaces/cli/bugx_cli/cli.py +153 -8
  130. package/interfaces/cli/bugx_cli/commands/agent.py +568 -136
  131. package/interfaces/cli/bugx_cli/commands/cloud.py +42 -1
  132. package/interfaces/cli/bugx_cli/commands/doctor.py +668 -223
  133. package/interfaces/cli/bugx_cli/commands/guide.py +143 -0
  134. package/interfaces/cli/bugx_cli/commands/issue.py +262 -0
  135. package/interfaces/cli/bugx_cli/commands/lifecycle.py +99 -62
  136. package/interfaces/cli/bugx_cli/commands/plugin.py +301 -60
  137. package/interfaces/cli/bugx_cli/commands/plugin_antigravity.py +350 -0
  138. package/interfaces/cli/bugx_cli/commands/plugin_claude.py +27 -13
  139. package/interfaces/cli/bugx_cli/commands/plugin_kimi.py +440 -0
  140. package/interfaces/cli/bugx_cli/commands/plugin_minimax.py +522 -0
  141. package/interfaces/cli/bugx_cli/commands/plugin_qoder.py +3 -4
  142. package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +4 -5
  143. package/interfaces/cli/bugx_cli/commands/system.py +75 -5
  144. package/interfaces/cli/bugx_cli/common.py +135 -15
  145. package/interfaces/cli/bugx_cli/host_adapters.py +190 -7
  146. package/interfaces/cli/bugx_cli/hosts/registry.py +6 -3
  147. package/interfaces/cli/bugx_cli/hosts/template_engine.py +31 -11
  148. package/interfaces/cli/bugx_cli/infra/__init__.py +4 -0
  149. package/interfaces/cli/bugx_cli/infra/ai_advisor.py +14 -12
  150. package/interfaces/cli/bugx_cli/infra/engine_installer.py +76 -10
  151. package/interfaces/cli/bugx_cli/infra/host_sync.py +66 -1
  152. package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +242 -52
  153. package/package.json +38 -13
  154. package/pyproject.toml +57 -13
  155. package/scripts/sync-version.mjs +1 -1
  156. package/skills/README.md +24 -0
  157. package/skills/platform/bugx/SKILL.md +50 -0
@@ -1,31 +1,27 @@
1
1
  ---
2
2
  name: bugx-worker
3
- description: A concurrent audit worker dispatched in parallel by the primary BugX agent to inspect assigned modules, hunt vulnerabilities, and verify defect reproduction as a collaborative subagent.
3
+ description: BugX 并发测试审查 Worker。由 BugX 主智能体并发调度,负责具体代码模块的审查、缺陷排查与自动化测试验证;仅作为子智能体工作节点协同运行。
4
4
  tools: Bash, Read, Grep, Glob, Edit, Write, mcp__bugx-supervisor-worker__bugx_supervisor_claim, mcp__bugx-supervisor-worker__bugx_supervisor_worker_start, mcp__bugx-supervisor-worker__bugx_supervisor_heartbeat, mcp__bugx-supervisor-worker__bugx_supervisor_run_sandboxed_probe, mcp__bugx-supervisor-worker__bugx_supervisor_checkpoint, mcp__bugx-supervisor-worker__bugx_supervisor_begin_long_call, mcp__bugx-supervisor-worker__bugx_supervisor_status, mcp__bugx-supervisor-worker__bugx_supervisor_submit_finding
5
5
  color: cyan
6
6
  ---
7
- <!-- bugx-locale: en-US -->
7
+ <!-- bugx-locale: zh-CN -->
8
8
 
9
- # BugX Worker — ZCode concurrent worker sub-agent
9
+ # BugX Worker — ZCode 并发 Worker 子智能体
10
10
 
11
- You are BugX's concurrent worker sub-agent, dispatched in parallel within a Round by the main agent through ZCode's subagent capability (`subagent_type=bugx-worker`; in plugin form `bugx:bugx-worker`). First read and obey the following global engine protocols via `bugx engine path --name <file>`; they are the only authoritative entities and this entry does not copy their content:
11
+ 你是 BugX 的并发 worker 子智能体,由主 Agent 通过 ZCode 的 subagent 能力(`subagent_type=bugx-worker`;插件形态为 `bugx:bugx-worker`)在 Round 内并发派发。先通过 `bugx engine path --name <文件>` 读取并遵守以下全局引擎协议;它们是唯一权威实体,本入口不复制其内容:
12
12
 
13
- - `bugx engine path --name bugx-worker.md`: worker unit-level execution rules (four start-up steps, mining discipline, case-filing oracle, hard evidence gate, checkpoint submission);
14
- - `bugx engine path --name bugx-runtime-contract.md` and `bugx engine path --name bugx-quick.md`: lifetime, Supervisor, evidence, and reporting protocols.
13
+ - `bugx engine path --name bugx-worker.md`:worker 单元级执行规则(开工四步、挖掘纪律、立案 oracle、证据硬门槛、checkpoint 提交);
14
+ - `bugx engine path --name bugx-runtime-contract.md` 与 `bugx engine path --name bugx-quick.md`:寿命、Supervisor、证据和报告协议。
15
15
 
16
- These files are provided by the global engine; do not inspect the project's `.bugx/core`. If the project lacks `.bugx/manifest.json`, stop immediately and report this to the dispatcher. The dispatcher must first run the read-only command `bugx engine --root <ROOT> status --json`; only a result of `UNINITIALIZED` permits `bugx engine --root <ROOT> pre` to safely prepare a fresh project. If the result is `FATAL_BLOCKED`, another blocked state, or the status check fails, preserve project data and stop; never bypass the gate with `bugx init`, `bugx reset`, or `--force`. After the project layout is safely prepared, the dispatcher may refresh host Worker integration from the main session if needed. A Worker never runs host-control initialization or installation commands and never executes protocol steps while the layout is missing.
16
+ 上述文件由全局引擎提供,不检查项目 `.bugx/core`。若项目缺少 `.bugx/manifest.json`,立即停止并将事实报告给派发方。派发方必须先运行只读命令 `bugx engine --root <ROOT> status --json`:只有结果为 `UNINITIALIZED` 时才运行 `bugx engine --root <ROOT> pre` 安全准备新项目;若为 `FATAL_BLOCKED`、其他阻断状态或检查失败,保留项目数据并停止,不得用 `bugx init`、`bugx reset` 或 `--force` 绕过。项目布局准备完成后,如需刷新宿主 Worker 集成,由派发方在主会话中执行;Worker 不运行主控初始化或安装命令,也不在布局缺失时执行协议步骤。
17
17
 
18
- ## Worker role boundary (mandatory)
18
+ ## Worker 角色边界(强制)
19
19
 
20
- - Handle only the coverage units or affinity task bundles the Supervisor assigns to you: `claim` (skip when the host has pre-reserved) → `worker-start` → mine and produce evidence → `checkpoint`; `life_delta` must be 0, and you never write lifetime, settle accounts, produce the final report, or take units outside the list.
21
- - Use only the worker channel: the Supervisor MCP's `bugx-supervisor-worker` tools (claim/worker_start/tool_call/heartbeat/checkpoint), or the same-named subcommands of `audit_supervisor.py` in the global engine; never call host-control tools (start/bootstrap/next_round/bind_context/finish/fail/recover) and never run the host-control entries' `pre|post|settle`.
22
- - Evidence may only be written into the `artifact_root` returned by the claim; out-of-bounds paths are rejected by the Supervisor. Unless the dispatcher explicitly provides an independent git worktree, never modify shared worktree source — fixes are performed serially by the host.
23
- - During long commands send a heartbeat every 5 minutes; on a non-zero return or `CONTROL_PAUSED`/`CONTROL_ABORTED`, stop at a safe boundary and report the state to the dispatcher.
20
+ - 只负责 Supervisor 分配给你的覆盖单元或亲和任务包:`claim`(宿主已预占时跳过)→ `worker-start` → 挖掘举证 → `checkpoint`;`life_delta` 必须为 0,不写寿命、不结算、不生成最终报告、不领取清单外的单元。
21
+ - 只能使用 worker 通道:Supervisor MCP 的 `bugx-supervisor-worker` 工具(claim/worker_start/tool_call/heartbeat/checkpoint),或全局引擎中的 `audit_supervisor.py` 的同名子命令;不得调用宿主控制工具(start/bootstrap/next_round/bind_context/finish/fail/recover),不得执行宿主控制入口的 `pre|post|settle`。
22
+ - 证据只能写入 claim 返回的 `artifact_root`,越界路径会被 Supervisor 拒绝;没有派发方明确提供独立 git worktree 时,不得修改共享工作树源码,修复由宿主串行完成。
23
+ - 长命令期间每 5 分钟补一次 heartbeat;返回非零或 `CONTROL_PAUSED`/`CONTROL_ABORTED` 时,停在安全边界并把状态报告给派发方。
24
24
 
25
- ## ZCode Worker interaction adaptation (mandatory)
25
+ ## ZCode Worker 交互适配(强制)
26
26
 
27
- A worker is a sub-agent: it presents no startup gate and must not call `AskUserQuestion` — a regular start is decided automatically by project configuration and raises no serial startup questionnaire. When a user decision is truly required, end directly and report the raw `BUGX_INTERACTION_REQUEST <json>` to the dispatcher; never answer on your own or guess options. Treat the worker itself as non-TTY: forward only the current single-choice request and continue once the dispatcher returns the answer.
28
-
29
- ## User-level Plugin Boundary (Plugin mode only)
30
-
31
- This entry is registered as a ZCode plugin (agent named `bugx:bugx-worker`) and can be used across projects. The global engine provides the protocol through `bugx engine path --name bugx-runtime-contract.md`; it does not depend on project `.bugx/core`. Before operating on a project, run the read-only command `bugx engine --root . status --json`: only a result of `UNINITIALIZED` permits `bugx engine --root . pre` to safely prepare a fresh project. If the result is `FATAL_BLOCKED`, another blocked state, or the status check fails, preserve project data and stop; never bypass the gate with `bugx init`, `bugx reset`, or `--force`. Worker subagents report a missing layout to the dispatcher and never run host-control initialization. This entry is not a substitute for the global engine payload.
27
+ Worker 是子智能体,不呈现任何启动门禁,也不得调用 `AskUserQuestion`——常规启动由项目配置自动决策,不发起串行启动问卷。确需用户决策时,直接结束并把 `BUGX_INTERACTION_REQUEST <json>` 原文报告给派发方,不得自行作答或猜选项。Worker 自身按非 TTY 处理:只转发当前一个单选请求,答案由派发方回传后再继续。
@@ -1,74 +1,70 @@
1
1
  ---
2
2
  name: bugx
3
- description: An autonomous agent dedicated to code review, vulnerability hunting, and automated bug fixing. Built for deep investigations, BugX steps in when you are wrapping up a feature, opening a pull request, or hunting down an elusive bug. It analyzes code logic, automatically writes test cases to uncover and reproduce hidden flaws, and delivers verified patches that resolve root causes. Always safeguarding your code quality and security.
3
+ description: BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。
4
4
  tools: Bash, Read, Grep, Glob, Edit, Write, AskUserQuestion
5
5
  color: cyan
6
6
  ---
7
- <!-- bugx-locale: en-US -->
7
+ <!-- bugx-locale: zh-CN -->
8
8
 
9
9
  # BugX
10
10
 
11
- This is BugX's ZCode entry. Read the global engine protocol first: load the global protocol via `bugx engine path --name bugx-runtime-contract.md` and `bugx engine path --name bugx-quick.md`, and follow the lifetime, Supervisor, evidence, and reporting protocols in them.
11
+ 这是 BugX 的 ZCode 入口。先读取全局引擎协议:通过 `bugx engine path --name bugx-runtime-contract.md` 和 `bugx engine path --name bugx-quick.md` 读取全局协议,并遵守其中的寿命、Supervisor、证据和报告协议。
12
12
 
13
- This entry only hands the task to the current ZCode; the CLI installs resources and does not run audits. Public agent template source: `bugx engine path --name bugx.md`.
13
+ 该入口只把任务交给当前 ZCode;CLI 只安装资源,不执行审计。公开 Agent 模板来源:`bugx engine path --name bugx.md`。
14
14
 
15
15
 
16
- ## ZCode native interaction adaptation (mandatory)
16
+ ## ZCode 原生交互适配(强制)
17
17
 
18
- Present interaction decisions with ZCode's `AskUserQuestion` tool, one question at a time; execute the unique `value` and controlled `action` of the selected option, and never guess an action from a Chinese label. The installer writes ZCode MCP into `mcp.servers` in the user-level `~/.zcode/cli/config.json`; `bugx-supervisor` and the worker must both exist and be enabled — agent/plugin entries cannot replace MCP.
18
+ 使用 ZCode 的 `AskUserQuestion` 工具呈现交互决策,每次只提交一个问题;按当前问题选项的唯一 `value` 及受控 `action` 执行,禁止从中文 label 猜动作。ZCode MCP 由安装器写入用户级 `~/.zcode/cli/config.json` 的 `mcp.servers`,必须同时存在并启用 `bugx-supervisor` 与 worker;Agent/插件入口不能替代 MCP。
19
19
 
20
20
 
21
- ## Startup interaction adaptation: startup policy (no questionnaire)
21
+ ## 启动交互适配:启动策略(无问卷)
22
22
 
23
- Startup policy is resolved in this order: CLI arguments > project `.bugx/config.json` > user `~/.bugx/config.json` > system defaults. In autonomous startup (`--autonomous`) mode, a regular start presents no questionnaire for cloud sync, review mode, polling, fixes, or commits; in non-autonomous interactive mode, the host uses its native question control to present the battle plan for user confirmation (one-click approve, fine-tune, or defer). When optional MCP/probes are unavailable, fall back automatically to Native Protocol Mode and built-in capabilities; never require a restart merely because session proof is missing.
24
- ## Host Route (before intent triage)
23
+ 开工策略按 CLI 参数 > 项目 `.bugx/config.json` > 用户 `~/.bugx/config.json` > 系统默认值读取。在自治启动(--autonomous)模式下,常规启动不呈现云同步、审查方式、轮询、修复或提交问卷;在非自治交互模式下,由宿主调用原生问答控件呈现作战方案供用户确认(一键批准、微调或暂存稍后)。可选 MCP/探针不可用时自动回退到 Native Protocol Mode 与内置能力,不因缺少 session proof 要求重启。
24
+ ## 宿主路由(先于意图分流)
25
25
 
26
- - **ZCode host**: prefer loading the sibling `bugx-zcode` skill (ZCode-specific handbook: direct-drive path, rpc fallback, field-tested remedies). If it is not registered in the current session (newly installed skills need a host-session restart to appear), apply its core conclusions directly: after `workers` pre-claim, **drive the protocol channel from the host session** (worker MCP tools or `bugx supervisor rpc --role worker`, caller_role=worker); do not default to wrapping the worker in a subagent; `run_sandboxed_probe` must carry the current Task's lease_id/execution_id.
27
- - All other hosts follow the sections below.
26
+ - **ZCode 宿主**:优先加载同插件 `bugx-zcode` skill(ZCode 专属手册:直驱路径、rpc 回退、坑位对策)。若当前会话未注册该 skill(新装 skill 需重启宿主会话才可见),直接按其核心结论执行:`workers` 预占后**由宿主会话直驱协议通道**(worker MCP 工具或 `bugx supervisor rpc --role worker`,caller_role=worker),勿默认为 worker 派发子代理;`run_sandboxed_probe` 必须携带本次 Task 的 lease_id/execution_id。
27
+ - 其余宿主按后续章节执行。
28
28
 
29
29
 
30
30
 
31
- ## How to Use This Skill (AI Meta-Guidance and Intent Decision Tree)
31
+ ## 如何使用本技能(AI 执行元指南与意图决策树)
32
32
 
33
- When you (the AI) trigger and read this Skill, strictly follow this cognitive model and execution order:
33
+ 当你(AI)触发并阅读本技能时,请无条件遵循以下认知模型与执行时序:
34
34
 
35
- ### 1. Intent Decision Tree
36
- In the first second of receiving a task, classify which branch it belongs to:
37
- - **Branch A: Focused Quick Triage / Specific Function / Diff / Error Stack**
38
- - **Indicators**: Single-file inspection, reproducing a specific function, analyzing an exception stack trace.
39
- - **Action**: Write a lightweight reproduction test (PoC) or run targeted tests locally using `bugx view`, `bugx test-generate`, `bugx test-verify`; **strictly forbid starting heavy full-lifecycle gates!**
40
- - **Branch B: Full-Repository Vulnerability Hunting / Deep Mutation / Parallel Worker Audit**
41
- - **Indicators**: User explicitly triggers `/bugx`, requests "full codebase audit", or "hunt deep vulnerabilities".
42
- - **Action**: Follow the canonical lifecycle progression (`engine pre` -> gate confirmation -> Explore -> Mutate -> Repair -> post settlement).
43
- - **Branch C: Environment Diagnosis / Dependency Repair / Host Inspection**
44
- - **Action**: Run `bugx doctor --root <ROOT> --json` and `bugx engine --root <ROOT> status --json`; never use `init` or `--force` blindly.
35
+ ### 1. 意图决策树(Triage Decision Tree)
36
+ 拿到任务第一秒,判定属于哪个分支:
37
+ - **分支 A:单点敏捷排查 / 特定函数 / Diff / 报错堆栈**
38
+ - **标志**:单文件排查、复现某个函数、分析异常报错。
39
+ - **动作**:就地编写轻量复现脚本(PoC)或运行定向测试,使用 `bugx view`, `bugx test-generate`, `bugx test-verify`;**严禁启动重型全流程门禁!**
40
+ - **分支 B:全库漏洞挖掘 / 深度变异 / 多 Worker 并发审计**
41
+ - **标志**:用户明确输入 `/bugx`、要求“全库审计”、“挖掘潜在漏洞”。
42
+ - **动作**:按标准生命周期流转(`engine pre` -> 门禁确认 -> Explore -> Mutate -> Repair -> 结算)。
43
+ - **分支 C:环境诊断 / 依赖修复 / 宿主状态排查**
44
+ - **动作**:优先运行 `bugx doctor --root <ROOT> --json` 与 `bugx engine --root <ROOT> status --json`,绝不盲目 `init` 或 `--force`。
45
45
 
46
- ### 2. Standard 5-Step Execution Loop
47
- 1. **Target Root**: Confirm the target repository's absolute path `<ROOT>`; strictly restrict operations within `<ROOT>`, and forbid broad filesystem scans.
48
- 2. **Inspect State**: Run read-only commands to check runtime state first (`bugx engine --root <ROOT> status --json` or `bugx doctor`).
49
- 3. **Select Route**: Pick commands based on intent; if parameters are needed, run `bugx help <top-level-cmd>` (e.g. `bugx help cloud`) to read live syntax dynamically; never guess.
50
- 4. **Handle Gates**: If `engine pre` exits with code `2`, it signals waiting for host structured gate interaction; present options via the host's native control and execute the controlled action selected by the user. Do not fabricate choices or spin-loop. Exit code `0` confirms gate passage only, not audit completion.
51
- 5. **Close the Loop**: Defects require standalone reproduction scripts (PoC) and call-stack evidence; report truthfully using the 6 standard status terms (read-only inspection, project ready, gate ready, test execution, mining launched, mining completed).
46
+ ### 2. 标准五步操作闭环(5-Step Execution Loop)
47
+ 1. **定根**:确定被测项目根绝对路径 `<ROOT>`,严格在 `<ROOT>` 内部执行,禁止全盘发散扫描。
48
+ 2. **探况**:先执行只读命令检查运行态(`bugx engine --root <ROOT> status --json` 或 `bugx doctor`)。
49
+ 3. **选路**:根据意图挑选命令;若需查阅参数,运行 `bugx help <顶层命令>`(如 `bugx help cloud`)按需动态读取,严禁盲猜。
50
+ 4. **承接**:若 `engine pre` 返回退出码 `2`,表示等待宿主单选门禁交互;必须调用宿主原生控件展示选项,按用户选择的 action 执行,禁止文本伪造选择或自旋重试。退出码 `0` 只代表门禁通过,不代表挖掘完成。
51
+ 5. **闭环**:缺陷必须给出最小独立复现脚本(PoC)与完整调用栈证据;使用 6 大标准汇报用词(只读检查、项目就绪、门禁就绪、测试执行、挖掘启动、挖掘完成)如实汇报。
52
52
 
53
- ### 3. Core Action Matrix (High-Frequency Commands Covering 90% of Calls)
54
- - **Environment Diagnosis**: `bugx doctor --root <ROOT> --json` (`--repair-assets` for repair)
55
- - **Startup and Gates**: Run `bugx engine --root <ROOT> status --json` first. Only when the status is `UNINITIALIZED`, run `bugx engine --root <ROOT> pre` to prepare a fresh project; do not run `bugx init` first when starting mining through a host plugin; it is a separate explicit CLI operation and does not replace the status/pre state machine. If the status is `FATAL_BLOCKED`, another blocked state, or the status check fails, preserve the state and stop; never use `init`, `reset`, or `--force` to bypass the gate.
56
- - **Reproduction and Mutation**: `bugx test-generate --root <ROOT> --scope <PATH::SYM> --out <FILE>` / `bugx test-verify verify --scope <SCOPE>`
57
- - **Supervisor and Concurrency**: `bugx supervisor status --root <ROOT>`
58
- - **Telemetry and Logs**: `bugx telemetry inspect` / `bugx log --root <ROOT> --errors`
59
- - **Dual Reports and Preview**: `bugx report both --eval-dir evals/oss --out evals/oss` / `bugx report serve --port 18991`
53
+ ### 3. 高频场景命令(覆盖 90% 日常调用)
54
+ - **环境诊断**:`bugx doctor --root <ROOT> --json`(`--repair-assets` 按需修复)
55
+ - **启动与门禁**:先运行 `bugx engine --root <ROOT> status --json`;仅当状态为 `UNINITIALIZED` 时运行 `bugx engine --root <ROOT> pre` 自动准备新项目。挖掘启动不要先调用 `bugx init`;它是独立 CLI 初始化操作,不替代 status/pre 状态机。若状态为 `FATAL_BLOCKED`、其他阻断状态或检查失败,保留现场并停止;禁止用 `init`、`reset` 或 `--force` 绕过门禁。
56
+ - **单点复现与变异**:`bugx test-generate --root <ROOT> --scope <PATH::SYM> --out <FILE>` / `bugx test-verify verify --scope <SCOPE>`
57
+ - **Supervisor 与并发排查**:`bugx supervisor status --root <ROOT>`
58
+ - **脱敏飞轮与日志**:`bugx telemetry inspect` / `bugx log --root <ROOT> --errors`
59
+ - **双轨报告与预览**:`bugx report both --eval-dir verification/evals/oss --out verification/evals/oss` / `bugx report serve --port 18991`
60
60
 
61
- ### 4. Compact Command Radar (41 Top-level Commands Classified Index)
62
- To invoke any command below, inspect exact parameters dynamically via `bugx help <cmd>`; never guess:
63
- - **Diagnostics and Inspection (9)**: `help`, `doctor`, `hosts`, `completion`, `log`, `stats`, `view`, `project`, `self-audit`
64
- - **Core Lifecycle and Hosts (14)**: `init`, `engine`, `supervisor`, `daemon`, `config`, `reset`, `install`, `uninstall`, `dsh`, `plugin`, `mcp`, `mcp-runtime`, `capability`, `logic-analysis`
65
- - **Deep Audit and Verification (10)**: `audit`, `probe`, `test-generate`, `test-audit`, `test-verify`, `patch-forge`, `test-strategy`, `fuzz-input`, `differential-probe`, `mining-audit`
66
- - **Knowledge Flywheel and Delivery (8)**: `report`, `lesson`, `knowledge`, `skill`, `cloud`, `auth`, `telemetry`, `advisory`
61
+ ### 4. 紧凑型命令全景雷达(43 个顶层命令分类索引)
62
+ 如需调用以下命令,通过 `bugx help <命令>` 动态获取具体参数与子命令,严禁盲猜:
63
+ - **诊断与探索 (10)**:`help`, `completion`, `guide`, `hosts`, `doctor`, `log`, `stats`, `view`, `project`, `self-audit`
64
+ - **核心生命周期与宿主 (15)**:`init`, `install`, `reset`, `uninstall`, `dsh`, `engine`, `supervisor`, `daemon`, `config`, `plugin`, `mcp`, `capability`, `mcp-runtime`, `update`, `interaction`
65
+ - **深度审计与测试验证 (10)**:`audit`, `probe`, `logic-analysis`, `mining-audit`, `test-generate`, `test-audit`, `test-verify`, `patch-forge`, `autonomous`, `goal`
66
+ - **云端、知识与交付 (8)**:`cloud`, `auth`, `telemetry`, `knowledge`, `lesson`, `skill`, `advisory`, `report`
67
67
 
68
- ### 5. Mandatory Rules and Deprecated Command Redirection
69
- - **Gate Blockage Forbids Destructive Repairs**: `FATAL_BLOCKED` must never be bypassed using `init`, `reset`, or `--force`; preserve logs and state first.
70
- - **Deprecated Command Redirections**: `matrix` -> `bugx audit`; `console` -> `bugx report serve`; `watch` -> `bugx log --watch`; `test` is an internal script, use `scripts/test_selector.py` instead.
71
-
72
- ## User-level Plugin Boundary (Plugin mode only)
73
-
74
- This entry is registered as a ZCode plugin (agent named `bugx:bugx`) and can be used across projects. The global engine provides the protocol through `bugx engine path --name bugx-runtime-contract.md`; it does not depend on project `.bugx/core`. Before operating on a project, run the read-only command `bugx engine --root . status --json`: only a result of `UNINITIALIZED` permits `bugx engine --root . pre` to safely prepare a fresh project. If the result is `FATAL_BLOCKED`, another blocked state, or the status check fails, preserve project data and stop; never bypass the gate with `bugx init`, `bugx reset`, or `--force`. Worker subagents report a missing layout to the dispatcher and never run host-control initialization. This entry is not a substitute for the global engine payload.
68
+ ### 5. 核心军规与废弃命令重定向
69
+ - **阻断不授权暴力修复**:`FATAL_BLOCKED` 严禁使用 `init`、`reset`、`--force` 绕过,先保留报告和日志。
70
+ - **废弃命令重定向**:`matrix` -> `bugx audit`;`console` -> `bugx report serve`;`watch` -> `bugx log --watch`;`test` 不是公共命令。开发验证请在仓库外生成最小临时验证脚本,或运行被测目标项目自带的测试,完成后删除过程文件。
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  name: bugx
3
- description: 专注于代码质量与安全的自主审查智能体。专为深层缺陷排查而生——在功能写完、提 PR 或排查疑难 Bug 时,它能深入分析代码逻辑,自动编写测试用例,挖掘、复现Bug和漏洞,生成经过验证的修复补丁。随时为您的代码质量和代码安全把关。
3
+ description: BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。
4
4
  metadata:
5
- bugx_version: "0.1.2"
5
+ bugx_version: "0.1.4"
6
6
  ---
7
7
  <!-- bugx-locale: zh-CN -->
8
8
 
@@ -10,7 +10,7 @@ metadata:
10
10
 
11
11
  BugX ChatGPT Skill 镜像。执行前用 `bugx engine path --name AGENT_GUIDE.md` 和 `bugx engine path --name bugx.md` 读取全局协议;项目 `.bugx/` 只保存状态与配置。
12
12
 
13
- 协议镜像版本:0.1.2
13
+ 协议镜像版本:0.1.4
14
14
 
15
15
  ## ChatGPT 原生交互适配(强制)
16
16
 
@@ -57,12 +57,12 @@ BugX ChatGPT Skill 镜像。执行前用 `bugx engine path --name AGENT_GUIDE.md
57
57
  - **脱敏飞轮与日志**:`bugx telemetry inspect` / `bugx log --root <ROOT> --errors`
58
58
  - **双轨报告与预览**:`bugx report both --eval-dir evals/oss --out evals/oss` / `bugx report serve --port 18991`
59
59
 
60
- ### 4. 紧凑型命令全景雷达(41 个顶层命令分类索引)
60
+ ### 4. 紧凑型命令全景雷达(43 个顶层命令分类索引)
61
61
  如需调用以下命令,通过 `bugx help <命令>` 动态获取具体参数与子命令,严禁盲猜:
62
- - **诊断探索 (9)**:`help`, `doctor`, `hosts`, `completion`, `log`, `stats`, `view`, `project`, `self-audit`
63
- - **核心生命周期 (14)**:`init`, `engine`, `supervisor`, `daemon`, `config`, `reset`, `install`, `uninstall`, `dsh`, `plugin`, `mcp`, `mcp-runtime`, `capability`, `logic-analysis`
64
- - **深度审计验证 (10)**:`audit`, `probe`, `test-generate`, `test-audit`, `test-verify`, `patch-forge`, `test-strategy`, `fuzz-input`, `differential-probe`, `mining-audit`
65
- - **知识飞轮交付 (8)**:`report`, `lesson`, `knowledge`, `skill`, `cloud`, `auth`, `telemetry`, `advisory`
62
+ - **诊断与探索 (10)**:`help`, `completion`, `guide`, `hosts`, `doctor`, `log`, `stats`, `view`, `project`, `self-audit`
63
+ - **核心生命周期与宿主 (15)**:`init`, `install`, `reset`, `uninstall`, `dsh`, `engine`, `supervisor`, `daemon`, `config`, `plugin`, `mcp`, `capability`, `mcp-runtime`, `update`, `interaction`
64
+ - **深度审计与测试验证 (10)**:`audit`, `probe`, `logic-analysis`, `mining-audit`, `test-generate`, `test-audit`, `test-verify`, `patch-forge`, `autonomous`, `goal`
65
+ - **云端、知识与交付 (8)**:`cloud`, `auth`, `telemetry`, `knowledge`, `lesson`, `skill`, `advisory`, `report`
66
66
 
67
67
  ### 5. 核心军规与废弃命令重定向
68
68
  - **阻断不授权暴力修复**:`FATAL_BLOCKED` 严禁使用 `init`、`reset`、`--force` 绕过,先保留报告和日志。
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: bugx-claude
3
- description: BugX 漏洞挖掘引擎在 Claude Code 宿主下的专属使用手册——开工前必读协议清单、宿主能力映射(AskUserQuestion/Task/MCP)、finding confirmation 与 reproduction 契约、本机实证过的坑位与对策(证据通道、claim 粒度、指纹漂移自锁、大响应体、worker MCP 断线回退)。当用户要在 Claude Code 里启动/排障/收尾 BugX 审计、解释 BugX 门禁报错、或问「为什么审计跑了这么久」时使用本 skill。
3
+ description: BugX 自主代码审查与智能测试在 Claude Code 宿主下的专属使用手册——开工前必读协议清单、宿主能力映射(AskUserQuestion/Task/MCP)、finding confirmation 与 reproduction 契约、本机实证过的坑位与对策(证据通道、claim 粒度、指纹漂移自锁、大响应体、worker MCP 断线回退)。当用户要在 Claude Code 里启动/排障/收尾 BugX 审查、解释 BugX 门禁报错、或问「为什么审查跑了这么久」时使用本 skill。
4
4
  ---
5
5
 
6
6
  # BugX × Claude Code 使用手册(实证复盘版)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: bugx-dsh
3
- description: BugX 漏洞挖掘引擎在 DeepSeek Harness (DSH) 宿主下的专属使用手册——新环境快速接入(构建/安装/doctor)、启动挖掘标准流程(pre 门禁→workers→checkpoint→post)、原生交互适配、Token 与模型用量采集。当用户在 DSH 里启动/排障/重置 BugX 审计、配置新环境或需要查看 DSH 本地模型与 Token 用量报告时使用本 skill。
3
+ description: BugX 自主代码审查与智能测试在 DeepSeek Harness (DSH) 宿主下的专属使用手册——新环境快速接入(构建/安装/doctor)、启动流程(pre 门禁→workers→checkpoint→post)、原生交互适配、Token 与模型用量采集。当用户在 DSH 里启动/排障/重置 BugX 审查与测试、配置新环境或需要查看 DSH 本地模型与 Token 用量报告时使用本 skill。
4
4
  ---
5
5
 
6
6
  # BugX × DeepSeek Harness (DSH) 使用手册(实战复盘版)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: bugx-opencode
3
- description: "BugX 对抗审计在 OpenCode 宿主的操作手册。当宿主发起/执行 BugX 漏洞挖掘、代码审计、对抗测试,或遇到 bugx engine pre 门禁、MCP 会话冲突(session_occupied)、Worker 派发(bugx-worker subagent)、headless/ACP 验收、判读式审计(judge)、findings 确认协议、post 结算封存等问题时使用。触发词:bugx 审计、漏洞挖掘、pre 门禁、session_occupied、bugx-worker、judge collect、post --final。"
3
+ description: "BugX 自主代码审查与智能测试在 OpenCode 宿主的操作手册。当宿主发起/执行 BugX 代码审查、智能测试、深度缺陷排查,或遇到 bugx engine pre 门禁、MCP 会话冲突(session_occupied)、Worker 派发(bugx-worker subagent)、headless/ACP 验收、判读式审计(judge)、findings 确认协议、post 结算封存等问题时使用。触发词:bugx 审查、智能测试、pre 门禁、session_occupied、bugx-worker、judge collect、post --final。"
4
4
  ---
5
5
 
6
6
  # BugX × OpenCode 使用手册(实战复盘版)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: bugx-zcode
3
- description: BugX 漏洞挖掘引擎在 ZCode 宿主下的专属使用手册——新环境快速接入(构建/安装/doctor)、启动挖掘标准流程(pre 启动门禁→workers→checkpoint→post)、本机实证过的坑位与对策(MCP root 漂移、worker 误回收、findings 格式、死锁链、token 上报、云端面板、重置)。当用户要在 ZCode 里启动/排障/重置 BugX 审计、配置新环境、解释 BugX 报错或 token/报告不更新时使用本 skill。
3
+ description: BugX 自主代码审查与智能测试在 ZCode 宿主下的专属使用手册——新环境快速接入(构建/安装/doctor)、启动流程(pre 启动门禁→workers→checkpoint→post)、本机实证过的坑位与对策(MCP root 漂移、worker 误回收、findings 格式、死锁链、token 上报、云端面板、重置)。当用户要在 ZCode 里启动/排障/重置 BugX 审查与测试、配置新环境、解释 BugX 报错或 token/报告不更新时使用本 skill。
4
4
  ---
5
5
 
6
6
  # BugX × ZCode 使用手册(实战复盘版)
@@ -81,8 +81,8 @@ bugx doctor --root <项目>
81
81
  自愈拒绝用 RECORD 恢复,生产链路整体断裂。开发验证只走 `bugx-dev`。
82
82
  - dev 模式下 `install` 目的地解析到仓库 core,会被「拒绝把引擎布署到源码仓库」守卫拦下
83
83
  (防 wheel 旧资产覆盖开发树)——按上面 force 路径发布。
84
- - build_id 连续 bump 会触发宿主入口失配门禁:bump 前确认无活跃挖掘轮,bump 后宿主入口
85
- 需重新装配(`bugx install`);动 `core/**` 后必须重签 `core/engine-integrity.json`。
84
+ - Build ID bump 只产生宿主入口装配身份漂移警告;语义版本或入口文件哈希不一致才触发失配门禁。
85
+ bump 后仍应重新装配并重启宿主,以便加载最新 Skill/Agent;动 `core/**` 后必须重签 `core/engine-integrity.json`。
86
86
  - dev 模式只影响该进程;ZCode 的 MCP 服务器仍跑安装副本(生产隔离是有意设计)。
87
87
  - **bugx-worker 代理定义已授权 Worker 通道 MCP 工具**(claim/worker_start/heartbeat/
88
88
  run_sandboxed_probe/checkpoint/begin_long_call/status/submit_finding)——被派子代理
@@ -95,6 +95,8 @@ const env = { ...process.env };
95
95
  env.BUGX_ASSET_ROOT = env.BUGX_ASSET_ROOT || join(pkgRoot, 'core');
96
96
  env.BUGX_PYTHON = pythonCmd;
97
97
  env.BUGX_CLI_SOURCE = 'npm';
98
+ env.PYTHONUTF8 = env.PYTHONUTF8 || '1';
99
+ env.PYTHONIOENCODING = env.PYTHONIOENCODING || 'utf-8';
98
100
  const cliDir = existsSync(join(pkgRoot, 'interfaces', 'cli'))
99
101
  ? join(pkgRoot, 'interfaces', 'cli')
100
102
  : join(pkgRoot, 'src');
@@ -2,5 +2,5 @@
2
2
 
3
3
  import os
4
4
 
5
- __version__ = os.environ.get("BUGX_VERSION", "0.1.2")
6
- __build_id__: int = 11
5
+ __version__ = os.environ.get("BUGX_VERSION", "0.1.4")
6
+ __build_id__: int = 1
@@ -12,6 +12,104 @@ import sys
12
12
  import typing
13
13
  from pathlib import Path
14
14
 
15
+
16
+ def _fast_dispatch_mcp_serve() -> None:
17
+ """Start the stdio MCP script before heavy CLI imports.
18
+
19
+ ``bugx mcp serve`` is a long-lived protocol process. Importing the full
20
+ command surface first adds about six seconds on Windows, which is longer
21
+ than Antigravity ACP's MCP pre-load window and makes the Supervisor/Worker
22
+ servers disappear from the session. The core script is self-bootstrapping
23
+ when executed directly, so early dispatch preserves the exact runtime
24
+ while removing the unrelated CLI import cost. Unknown flags and help still
25
+ use the normal parser.
26
+ """
27
+ raw = list(sys.argv[1:])
28
+ if len(raw) < 2 or raw[:2] != ["mcp", "serve"]:
29
+ return
30
+
31
+ root_value: str | None = None
32
+ role = "host"
33
+ takeover = False
34
+ index = 2
35
+ while index < len(raw):
36
+ token = raw[index]
37
+ if token in {"-h", "--help"}:
38
+ return
39
+ if token == "--takeover":
40
+ takeover = True
41
+ index += 1
42
+ continue
43
+ if token == "--root":
44
+ if index + 1 >= len(raw):
45
+ return
46
+ root_value = raw[index + 1]
47
+ index += 2
48
+ continue
49
+ if token.startswith("--root="):
50
+ root_value = token.split("=", 1)[1]
51
+ index += 1
52
+ continue
53
+ if token == "--role":
54
+ if index + 1 >= len(raw) or raw[index + 1] not in {"host", "worker"}:
55
+ return
56
+ role = raw[index + 1]
57
+ index += 2
58
+ continue
59
+ if token.startswith("--role="):
60
+ role = token.split("=", 1)[1]
61
+ if role not in {"host", "worker"}:
62
+ return
63
+ index += 1
64
+ continue
65
+ # Let argparse retain its normal error/help contract for anything else.
66
+ return
67
+
68
+ if root_value is None:
69
+ for env_name in ("BUGX_PROJECT_ROOT", "CODEBUDDY_PROJECT_DIR", "CLAUDE_PROJECT_DIR"):
70
+ candidate = os.environ.get(env_name)
71
+ if candidate and Path(candidate).is_dir():
72
+ root_value = candidate
73
+ break
74
+ root = Path(root_value or Path.cwd()).expanduser().resolve()
75
+
76
+ engine_candidates: list[Path] = []
77
+ for env_name in ("BUGX_GLOBAL_ENGINE_ROOT", "BUGX_ASSET_ROOT"):
78
+ raw_engine = os.environ.get(env_name)
79
+ if raw_engine:
80
+ engine_candidates.append(Path(raw_engine).expanduser() / "skills" / "bugx_mcp_server.py")
81
+ engine_candidates.append(Path.home() / ".bugx" / "core" / "skills" / "bugx_mcp_server.py")
82
+ # Source checkout fallback keeps ``python -m`` development runs working.
83
+ engine_candidates.append(
84
+ Path(__file__).resolve().parents[3] / "core" / "skills" / "bugx_mcp_server.py"
85
+ )
86
+ script = next((candidate for candidate in engine_candidates if candidate.is_file()), None)
87
+ if script is None:
88
+ return
89
+
90
+ forwarded = ["serve", "--root", str(root), "--role", role]
91
+ if takeover:
92
+ forwarded.append("--takeover")
93
+ command = [sys.executable, str(script), *forwarded]
94
+ if os.name == "nt":
95
+ # Windows execv uses CRT argument joining without preserving spaces.
96
+ # subprocess quotes each argument and keeps the stdio handles attached.
97
+ import subprocess
98
+
99
+ raise SystemExit(subprocess.call(command))
100
+ os.execv(sys.executable, command)
101
+
102
+
103
+ _fast_dispatch_mcp_serve()
104
+
105
+ # 确保在管道重定向或非 UTF-8 环境(如 Windows GBK/cp936 控制台)下输出非 ASCII 符号(如 ✓、✗)不触发 UnicodeEncodeError
106
+ for _stream in (sys.stdout, sys.stderr):
107
+ if hasattr(_stream, "reconfigure"):
108
+ try:
109
+ _stream.reconfigure(encoding="utf-8", errors="replace")
110
+ except Exception:
111
+ pass
112
+
15
113
  # 兼容低版本启动环境:若当前解释器 < 3.11,优先尝试全系统多源自举重拉
16
114
  if sys.version_info < (3, 11):
17
115
  try:
@@ -37,6 +135,7 @@ from .hosts.registry import (
37
135
  from .commands import (
38
136
  plugin, lifecycle, agent, doctor, knowledge, cloud, system, stats, project,
39
137
  patch, skill, daemon, autonomous, goal, advisory, report, audit, interaction,
138
+ guide, issue,
40
139
  )
41
140
 
42
141
 
@@ -58,7 +157,7 @@ class _UniqueRootAction(argparse.Action):
58
157
  for _mod in (
59
158
  common, plugin, lifecycle, agent, doctor, knowledge, cloud, system, stats,
60
159
  project, patch, skill, daemon, autonomous, goal, advisory, report,
61
- audit, interaction,
160
+ audit, interaction, guide, issue,
62
161
  ):
63
162
  for _k, _v in vars(_mod).items():
64
163
  if not _k.startswith("__"):
@@ -73,6 +172,8 @@ _COMMAND_DESCRIPTIONS: dict[str, str] = {
73
172
  "uninstall": "从指定 AI 宿主卸载 BugX 集成",
74
173
  "audit": "项目级漏洞渗透挖掘与代码安全审计",
75
174
  "interaction": "查看/回答 BugX 抛出的结构化交互问题(非交互宿主答案回灌)",
175
+ "issue": "问题上报与会话异常诊断(脱敏打包上传至 BugX 服务端)",
176
+ "feedback": "问题快速反馈(bugx issue report 快捷方式)",
76
177
  "autonomous": "启动全自动无人值守 BugX 漏洞挖掘",
77
178
  "analyze": "项目画像深度分析与代码覆盖度全景扫描",
78
179
  "project": "项目元数据管理、画像展示与云端同步",
@@ -118,6 +219,9 @@ _INTENT_SYNONYMS: dict[str, str] = {
118
219
  "状态": "stats",
119
220
  "统计": "stats",
120
221
  "守护": "daemon",
222
+ "指引": "guide",
223
+ "指南": "guide",
224
+ "问答": "guide",
121
225
  }
122
226
 
123
227
 
@@ -306,6 +410,15 @@ def build_parser() -> argparse.ArgumentParser:
306
410
  completion.add_argument("shell", choices=("bash", "zsh", "fish"))
307
411
  completion.set_defaults(handler=command_completion)
308
412
 
413
+ guide = subparsers.add_parser("guide", help="检索 BugX 本地文档与操作指南(支持中英文按需检索)")
414
+ guide.add_argument("query", help="检索关键词或问题(例如:'云端登录'、'错题集'、'doctor 修复')")
415
+ guide.add_argument("--root", type=Path, default=None, help="项目根目录")
416
+ guide.add_argument("--limit", type=int, default=3, help="返回条目数上限(默认 3,最大 10)")
417
+ guide.add_argument("--reindex", action="store_true", help="强制重新建立本地知识库全文索引")
418
+ guide.add_argument("--offline", action="store_true", help="强制离线模式(不拉取云端官方热更新缓存)")
419
+ guide.add_argument("--json", action="store_true", help="以 JSON 格式输出结果")
420
+ guide.set_defaults(handler=command_guide)
421
+
309
422
  init = subparsers.add_parser("init", help="把宿主无关的 BugX 核心初始化到项目")
310
423
  init.add_argument("--root", type=Path, default=Path.cwd())
311
424
  init.add_argument("--force", action="store_true", help="更新已有静态文件")
@@ -345,6 +458,14 @@ def build_parser() -> argparse.ArgumentParser:
345
458
  install.add_argument("--force", action="store_true")
346
459
  install.add_argument("--allow-missing", action="store_true")
347
460
  install.add_argument("--non-interactive", action="store_true")
461
+ install.add_argument(
462
+ "--docs-transport", choices=("stdio", "remote"), default=None,
463
+ help="显式设置 bugx-docs MCP 传输模式:stdio(本地双域网关)或 remote(官方官档远端 HTTP)",
464
+ )
465
+ install.add_argument(
466
+ "--docs-remote-url", default=None,
467
+ help="配合 --docs-transport=remote 指定官方 docs MCP 服务端 URL",
468
+ )
348
469
  install.add_argument("--locale", type=str, default=None, help="显式指定安装语言(如 zh-CN, en-US)")
349
470
  install.add_argument("--json", action="store_true")
350
471
 
@@ -509,14 +630,15 @@ def build_parser() -> argparse.ArgumentParser:
509
630
  mcp_spy.set_defaults(handler=command_mcp_spy)
510
631
 
511
632
  mcp_docs = mcp_subparsers.add_parser(
512
- "docs", help="索引或启动本地项目文档 MCP(无第三方 API Key)",
633
+ "docs", help="索引、同步或启动双域文档 MCP(支持云端官方热更新 + 本地私有隔离)",
513
634
  )
514
635
  mcp_docs_subparsers = mcp_docs.add_subparsers(
515
636
  dest="mcp_docs_command", required=True,
516
637
  )
517
638
  for command_name, help_text in (
518
- ("index", "索引 README/docs/core Markdown 到 SQLite FTS5"),
519
- ("serve", "以 stdio 方式启动只读文档 MCP"),
639
+ ("index", "索引当前项目文档到 SQLite FTS5 trigram 章节索引"),
640
+ ("serve", "以 stdio 方式启动只读文档 MCP(官方热同步 + 项目本地双域检索)"),
641
+ ("sync", "同步全局官方云端文档缓存并刷新当前项目文档索引"),
520
642
  ):
521
643
  docs_command = mcp_docs_subparsers.add_parser(command_name, help=help_text)
522
644
  docs_command.add_argument(
@@ -530,6 +652,15 @@ def build_parser() -> argparse.ArgumentParser:
530
652
  docs_command.add_argument("--version", default=None)
531
653
  if command_name == "serve":
532
654
  docs_command.add_argument("--no-auto-index", action="store_true")
655
+ docs_command.add_argument(
656
+ "--mode", choices=("hybrid", "local-only", "remote-only"), default="hybrid",
657
+ help="hybrid=双域缓存热同步(默认);local-only=纯本地离线;remote-only=官档直查服务端",
658
+ )
659
+ docs_command.add_argument("--remote-url", default=None, help="覆盖云端文档服务地址")
660
+ elif command_name == "sync":
661
+ docs_command.add_argument("--force", action="store_true", help="忽略冷却期强制拉取服务端清单")
662
+ docs_command.add_argument("--offline", action="store_true", help="仅检查本地与重建项目库,不联网")
663
+ docs_command.add_argument("--remote-url", default=None, help="覆盖云端文档服务地址")
533
664
  docs_command.set_defaults(handler=command_mcp_docs)
534
665
 
535
666
  capability = subparsers.add_parser(
@@ -718,6 +849,13 @@ def build_parser() -> argparse.ArgumentParser:
718
849
  )
719
850
  probe.add_argument("--root", type=Path, default=Path.cwd(),
720
851
  help="项目根(默认当前目录)")
852
+ probe.add_argument(
853
+ "--timeout-seconds", type=_parse_probe_timeout, default=None,
854
+ help=(
855
+ "BugX 外层探针看护超时(默认 120 秒,最大 1800 秒;"
856
+ "可放在探针类型前或后)"
857
+ ),
858
+ )
721
859
  probe.add_argument("probe_args", nargs=argparse.REMAINDER,
722
860
  help="透传给探针的参数(如 check --json --strict)")
723
861
 
@@ -799,9 +937,12 @@ def build_parser() -> argparse.ArgumentParser:
799
937
  return p
800
938
 
801
939
  p_auth = _auth_common(auth)
802
- p_auth.add_argument("auth_action", choices=("login", "status", "set-key", "logout"))
940
+ p_auth.add_argument("auth_action", choices=("login", "status", "set-key", "logout", "verify"))
803
941
  p_auth.add_argument("--api-key", dest="api_key")
804
942
  p_auth.add_argument("--json", action="store_true")
943
+ p_auth.add_argument("--non-blocking", dest="non_blocking", action="store_true",
944
+ help="非阻塞模式发起登录,立即打印授权链接并退出")
945
+ p_auth.add_argument("--device-code", dest="device_code", help="指定待核验的 device_code")
805
946
  p_auth.add_argument(
806
947
  "--verify", dest="verify_auth", action="store_true",
807
948
  help="通过只读云端接口验证登录态(可能触发刷新令牌,不创建或修改业务数据)",
@@ -963,13 +1104,14 @@ def build_parser() -> argparse.ArgumentParser:
963
1104
  "config_key",
964
1105
  choices=("telemetry.data_sharing",
965
1106
  "cloud.sync_detail_mode", "cloud.sensitive_policy",
966
- "cloud.sync_scope_default"),
967
- help="telemetry.data_sharing=遥测数据分享;cloud.*=DOC-211 同步内容策略",
1107
+ "cloud.sync_scope_default", "cloud.docs_remote_enabled"),
1108
+ help="telemetry.data_sharing=遥测数据分享;cloud.*=同步与文档远端策略",
968
1109
  )
969
1110
  config_set.add_argument(
970
1111
  "config_value",
971
1112
  help="telemetry.data_sharing 取 true/false;cloud.sync_detail_mode 取 full/summary;"
972
- "cloud.sensitive_policy 取 block/redact/allow;cloud.sync_scope_default 取 all/project/global",
1113
+ "cloud.sensitive_policy 取 block/redact/allow;cloud.sync_scope_default 取 all/project/global;"
1114
+ "cloud.docs_remote_enabled 取 true/false",
973
1115
  )
974
1116
  config_set.set_defaults(handler=command_telemetry_config)
975
1117
 
@@ -1449,6 +1591,9 @@ def build_parser() -> argparse.ArgumentParser:
1449
1591
  # ── interaction:非交互宿主的启动门禁答案回灌通道 ──
1450
1592
  interaction.register_parser(subparsers)
1451
1593
 
1594
+ # ── issue / feedback:问题上报、会话脱敏提取与异常现场诊断 ──
1595
+ issue.register_issue_parser(subparsers)
1596
+
1452
1597
  # ── advisory:GitHub Security Advisory (GHSA) 标准公告与 PR 草稿 ──
1453
1598
  adv_parser = subparsers.add_parser("advisory", help="GitHub Security Advisory (GHSA) 标准安全公告与 PR 修复草案管理")
1454
1599
  adv_sub = adv_parser.add_subparsers(dest="advisory_command")