bugx-cli 0.1.3 → 0.1.5

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 (167) hide show
  1. package/core/README.md +5 -3
  2. package/core/agent/agent_execution.py +7 -0
  3. package/core/assets/bugx-wechat-group.png +0 -0
  4. package/core/bugx.md +2 -2
  5. package/core/bugx_paths.py +10 -2
  6. package/core/bundled_docs/OVERVIEW.md +311 -0
  7. package/core/bundled_docs/README.md +10 -0
  8. package/core/bundled_docs/README_EN.md +278 -0
  9. package/core/bundled_docs/ai/01_AI_REFERENCE.md +838 -0
  10. package/core/bundled_docs/ai/02_AI_USAGE.md +161 -0
  11. package/core/bundled_docs/ai/03_AI_COMMANDS.md +322 -0
  12. package/core/bundled_docs/guides/01_USER_GUIDE.md +887 -0
  13. package/core/bundled_docs/guides/02_COMMANDS.md +935 -0
  14. package/core/bundled_docs/guides/03_TROUBLESHOOTING.md +763 -0
  15. package/core/bundled_docs/guides/04_CLOUD_AUTH_AND_SYNC_COOKBOOK.md +48 -0
  16. package/core/bundled_docs/guides/05_HOST_MATRIX_AND_DISPATCH.md +25 -0
  17. package/core/bundled_docs/guides/06_PROBES_AND_POC_COOKBOOK.md +49 -0
  18. package/core/bundled_docs/guides/07_LIFECYCLE_AND_RECOVERY_STATES.md +46 -0
  19. package/core/bundled_docs/guides/08_LESSONS_AND_PRIVACY_BOUNDARY.md +35 -0
  20. package/core/bundled_docs/hosts/bugx-claude_SKILL.md +326 -0
  21. package/core/bundled_docs/hosts/bugx-dsh_SKILL.md +229 -0
  22. package/core/bundled_docs/hosts/bugx-opencode_SKILL.md +129 -0
  23. package/core/bundled_docs/hosts/bugx-zcode_SKILL.md +459 -0
  24. package/core/bundled_docs/hosts/bugx_SKILL.md +118 -0
  25. package/core/bundled_docs/hosts/cline_bugx_SKILL.md +69 -0
  26. package/core/bundled_docs/hosts/platform_bugx_SKILL.md +50 -0
  27. package/core/bundled_docs/manifest.json +140 -0
  28. package/core/bundled_docs/reference/01_ENVIRONMENT_VARIABLES.md +422 -0
  29. package/core/bundled_docs/reference/04_REPOSITORY_TOPOLOGY.md +180 -0
  30. package/core/cli-help.txt +7 -3
  31. package/core/cloud_sync/cloud_client.py +81 -2
  32. package/core/cloud_sync/endpoint_router.py +22 -9
  33. package/core/cloud_sync/issue_uploader.py +297 -0
  34. package/core/cloud_sync/sensitive_filter.py +77 -7
  35. package/core/contracts/AGENT_GUIDE.md +3 -9
  36. package/core/contracts/README.md +1 -1
  37. package/core/contracts/bugx-runtime-contract.md +10 -20
  38. package/core/contracts/bugx-worker.md +1 -1
  39. package/core/coverage/coverage_ai_review.py +15 -11
  40. package/core/coverage/coverage_bootstrap.py +18 -13
  41. package/core/coverage/coverage_discovery.py +1 -1
  42. package/core/dev_harness/interaction_preset.py +1 -1
  43. package/core/engine-integrity.json +283 -159
  44. package/core/host_acp/README.md +4 -0
  45. package/core/host_acp/agnescode.py +128 -0
  46. package/core/host_acp/antigravity.py +153 -0
  47. package/core/host_runtime/README.md +3 -0
  48. package/core/host_runtime/adapters.py +5 -1
  49. package/core/host_runtime/antigravity.py +162 -0
  50. package/core/host_runtime/host_bootstrap.py +18 -7
  51. package/core/host_runtime/host_evaluators.py +4 -4
  52. package/core/host_runtime/host_registry.py +3 -1
  53. package/core/host_runtime/mcp_process_tracker.py +30 -3
  54. package/core/host_runtime/mcp_registry_gate.py +34 -11
  55. package/core/hosts/README.md +4 -0
  56. package/core/hosts/agnescode.py +415 -0
  57. package/core/hosts/antigravity.py +115 -0
  58. package/core/hosts/codex.py +3 -0
  59. package/core/hosts/dsh.py +42 -23
  60. package/core/hosts/minimax.py +5 -4
  61. package/core/hosts/opencode.py +11 -3
  62. package/core/i18n.py +94 -5
  63. package/core/infra/README.md +1 -1
  64. package/core/infra/build_info.py +2 -2
  65. package/core/infra/python_runtime.py +4 -1
  66. package/core/launch_phases/README.md +2 -2
  67. package/core/launch_phases/finding_confirm_phase.py +1 -1
  68. package/core/launch_phases/semantic_recon.py +3 -19
  69. package/core/launch_phases/startup_version_gate.py +2 -2
  70. package/core/launch_phases/supervisor_bridge.py +2 -0
  71. package/core/launch_phases/supervisor_degraded.py +7 -5
  72. package/core/launch_phases/verify_loop.py +3 -19
  73. package/core/ledger/README.md +1 -1
  74. package/core/ledger/finding_confirmation.py +1 -1
  75. package/core/ledger/finding_verification.py +2 -20
  76. package/core/ledger/fp_ledger.py +3 -19
  77. package/core/ledger/life_ledger.py +7 -33
  78. package/core/ledger/schema.py +1 -1
  79. package/core/locales/en-US.json +3 -3
  80. package/core/locales/zh-CN.json +3 -3
  81. package/core/mcp_handlers/supervisor_handlers.py +1 -1
  82. package/core/mcp_runtime_support/common.py +6 -0
  83. package/core/mcp_runtime_support/environment.py +88 -24
  84. package/core/metadata.txt +1 -1
  85. package/core/planning/README.md +1 -1
  86. package/core/planning/prompt_harness.py +2 -2
  87. package/core/planning/target_sandbox_manager.py +2 -0
  88. package/core/probes/codebase_memory_probe.py +43 -24
  89. package/core/probes/mobile_probe.py +1 -0
  90. package/core/probes/probe_registry.py +10 -7
  91. package/core/probes/sast_probe.py +1 -1
  92. package/core/probes/sca_scanner.py +1 -1
  93. package/core/project_profiler/constants.py +1 -1
  94. package/core/prompts/command_routing_en.md +6 -5
  95. package/core/prompts/command_routing_zh.md +6 -5
  96. package/core/repair/rsi_rounds.py +3 -0
  97. package/core/repair/self_heal.py +160 -6
  98. package/core/retrieval/README.md +1 -1
  99. package/core/retrieval/symbol_index.py +227 -52
  100. package/core/runtime/README.md +1 -1
  101. package/core/runtime/daemon_runner.py +3 -2
  102. package/core/runtime/project_init.py +1 -1
  103. package/core/runtime/scenario_eval.py +5 -1
  104. package/core/runtime/tool_install_targets.py +12 -2
  105. package/core/skills/README.md +4 -2
  106. package/core/skills/bugx_docs_cloud_sync.py +658 -0
  107. package/core/skills/bugx_docs_mcp_server.py +966 -140
  108. package/core/skills/bugx_mcp_server.py +9 -0
  109. package/core/skills/mcp_session_proof.py +3 -31
  110. package/core/supervisor/README.md +1 -1
  111. package/core/supervisor/finding_commit.py +3 -24
  112. package/core/supervisor/task_scheduler.py +5 -2
  113. package/core/supervisor/worker_execution.py +16 -3
  114. package/core/supervisor/worker_handoff.py +2 -2
  115. package/core/webui/docs_session_service.py +40 -2
  116. package/core/webui/mcp_inspector.py +6 -6
  117. package/ecosystem/integrations/cline/skills/bugx/SKILL.md +46 -46
  118. package/ecosystem/integrations/dsh/agents/bugx.md +2 -1
  119. package/ecosystem/integrations/dsh/mcp/package.json +1 -1
  120. package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +5 -5
  121. package/ecosystem/integrations/dsh/ui/package.json +1 -1
  122. package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +4 -4
  123. package/ecosystem/integrations/opencode/mcp-lock.json +1 -1
  124. package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
  125. package/ecosystem/integrations/pi/skills/bugx/SKILL.md +5 -5
  126. package/ecosystem/integrations/qoder/CONNECTORS.md +11 -23
  127. package/ecosystem/integrations/qoder/connector-meta.json +1 -1
  128. package/ecosystem/integrations/workbuddy/connector-meta.json +1 -1
  129. package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +8 -7
  130. package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +1 -1
  131. package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +1 -1
  132. package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +1 -1
  133. package/ecosystem/plugins/bugx/agents/bugx-worker.md +14 -18
  134. package/ecosystem/plugins/bugx/agents/bugx.md +45 -49
  135. package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +7 -7
  136. package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +2 -2
  137. package/interfaces/cli/bugx_cli/__init__.py +1 -1
  138. package/interfaces/cli/bugx_cli/cli.py +153 -8
  139. package/interfaces/cli/bugx_cli/commands/agent.py +376 -69
  140. package/interfaces/cli/bugx_cli/commands/audit.py +2 -1
  141. package/interfaces/cli/bugx_cli/commands/cloud.py +42 -1
  142. package/interfaces/cli/bugx_cli/commands/doctor.py +650 -223
  143. package/interfaces/cli/bugx_cli/commands/guide.py +143 -0
  144. package/interfaces/cli/bugx_cli/commands/issue.py +262 -0
  145. package/interfaces/cli/bugx_cli/commands/lifecycle.py +56 -26
  146. package/interfaces/cli/bugx_cli/commands/patch.py +5 -1
  147. package/interfaces/cli/bugx_cli/commands/plugin.py +306 -56
  148. package/interfaces/cli/bugx_cli/commands/plugin_antigravity.py +350 -0
  149. package/interfaces/cli/bugx_cli/commands/plugin_claude.py +2 -2
  150. package/interfaces/cli/bugx_cli/commands/plugin_kimi.py +154 -62
  151. package/interfaces/cli/bugx_cli/commands/plugin_minimax.py +308 -108
  152. package/interfaces/cli/bugx_cli/commands/system.py +11 -1
  153. package/interfaces/cli/bugx_cli/common.py +39 -8
  154. package/interfaces/cli/bugx_cli/host_adapters.py +46 -3
  155. package/interfaces/cli/bugx_cli/hosts/registry.py +3 -2
  156. package/interfaces/cli/bugx_cli/hosts/template_engine.py +21 -2
  157. package/interfaces/cli/bugx_cli/infra/__init__.py +4 -0
  158. package/interfaces/cli/bugx_cli/infra/ai_advisor.py +14 -12
  159. package/interfaces/cli/bugx_cli/infra/engine_installer.py +76 -10
  160. package/interfaces/cli/bugx_cli/infra/host_sync.py +66 -1
  161. package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +240 -50
  162. package/package.json +3 -2
  163. package/pyproject.toml +22 -2
  164. package/scripts/sync-version.mjs +1 -1
  165. package/skills/README.md +1 -2
  166. package/skills/platform/bugx/SKILL.md +50 -0
  167. package/skills/platform/bugx-user/SKILL.md +0 -92
@@ -415,8 +415,8 @@
415
415
  "prompt.tier.default.description": "General default model",
416
416
  "prompt.tier.explore.description": "High-throughput scanning model (Flash / Haiku / GPT-4o-mini), for large-scale unit and route exploration",
417
417
  "prompt.tier.gate.description": "Fast lightweight model (Flash / Haiku / GPT-4o-mini), for fast gates and baseline checks",
418
- "prompt.tier.mutate.description": "Deep reasoning model (Sonnet / DeepSeek-R1 / GPT-4o), for concurrency race, state simulation, and differential testing",
419
- "prompt.tier.repair.description": "High-precision code engineering model (Claude 3.5 Sonnet / Codex), for minimal TDD fix and unit test closure",
418
+ "prompt.tier.mutate.description": "Deep reasoning model (Claude Sonnet 5.5 / Gemini 4 Carbon / DeepSeek-R1 / GPT-4o), for concurrency race, state simulation, and differential testing",
419
+ "prompt.tier.repair.description": "High-precision code engineering model (Claude Sonnet 5.5 / Opus 5.5 / Codex), for minimal TDD fix and unit test closure",
420
420
  "prompt.workers.shared_instruction_body": "You are a BugX concurrent worker. The host has already atomically claimed the coverage unit(s) below; do not claim again.\n1. Resolve the global script with `bugx engine path --name audit_supervisor.py`, then confirm actual start (returned execution_id must stay unchanged; copy the preoccupied value verbatim, omit it when unconfirmed, and never generate/replace it):\n <Python> <global-engine>/audit_supervisor.py worker-start --root . \\\n --state {state_rel} --worker <claimed worker_id> --provider <provider>\n2. Complete exploration → test → evidence verification for assigned units; write all evidence to artifact_root returned by claim. Each coverage unit must have its own unique artifact file; never overwrite or modify it after submitting its checkpoint.\n Modifying shared source without host-provided git worktree is prohibited; fixes are performed serially by host;\n Do not write shared runtime, do not write life, do not run verify_life.py settle, do not generate final report.\n3. Submit checkpoint (life_delta must be JSON number 0, never string \\\"0\\\"; artifact_path must reside in own artifact_root):\n <Python> <global-engine>/audit_supervisor.py checkpoint --root . \\\n --state {state_rel} --worker <claimed worker_id> --input <payload.json>\n payload.json must contain unique and retryable checkpoint_id covering all claimed units. expected_revision may be included only when returned by the immediately preceding MCP response; otherwise omit it and never guess 0/1.\n coverage=covered is a coverage state; evidence.status must be passed with exit_code=0. Other evidence.status values are only failed/error/skipped/blocked; never put covered in evidence.status. Each candidate finding's evidence must be a list of objects `[{{\"path\": \"<relative_path>\", \"line\": <positive_int>}}]`, never a \"path:line\" string. If a finding sets `reproducible=true`, it must include a non-empty `reproduction` command or step list; otherwise do not mark it reproducible.\n4. Call bugx_supervisor_heartbeat immediately after a successful worker-start (your first liveness proof), then every <=5 minutes; before any long command (>60s probes/tests) call MCP bugx_supervisor_begin_long_call (expected_seconds<=1800, keep-alive window so the lease survives the command) before any long command (>60s probes/tests), then call bugx_supervisor_heartbeat every 5 minutes; leases will be reclaimed by host if stuck; do not treat ordinary claim as execution or call a project `.bugx/core` entry.\n4a. If a checkpoint is rejected (run_id/execution_receipt/cross-epoch), rewrite the probe output to a NEW file inside artifact_root and resubmit via the bounded finalizer (worker_checkpoint.py finalize, step 3 pattern) rebound to the current epoch; never blindly re-run probes.",
421
421
  "prompt.workers.shared_instruction_header": "【Shared Instructions】Paste the following block into each worker's Task prompt:",
422
422
  "prompt.workers.task_harness_banner": " [Active Stage Harness Injection Task Package]:",
@@ -454,7 +454,7 @@
454
454
  "host.entry.body.qoder_worker": "\n# BugX Worker — Qoder concurrent worker sub-agent\n\nYou are BugX's concurrent worker sub-agent, dispatched in parallel within a Round by the main agent through Qoder's subagent capability (`subagent_type=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:\n\n- `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);\n- `bugx engine path --name bugx-runtime-contract.md` and `bugx engine path --name bugx-quick.md`: lifetime, Supervisor, evidence, and reporting protocols.\n\nThese 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.\n\n## Worker role boundary (mandatory)\n\n- 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.\n- 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`.\n- 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.\n- 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.\n\n## Qoder Worker interaction adaptation (mandatory)\n\nA 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.\n",
455
455
  "plugin.zcode_plugin_boundary": "## User-level plugin boundary (plugin form only)\n\nThis entry is registered as a ZCode plugin (agent name `{agent_ref}`) and can be used across projects. 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`. This entry is not a substitute for the global engine payload.\n",
456
456
  "plugin.chatgpt_skill_banner": "This is the BugX ChatGPT Skill mirror. Before executing, read the global protocol via `bugx engine path --name AGENT_GUIDE.md` and `bugx engine path --name bugx.md`; the global engine is the only authoritative source for protocol and runtime.\n\nProtocol Mirror Version: {version}\n",
457
- "host.entry.section.commands": "## Host Route (before intent triage)\n\n- **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.\n- All other hosts follow the sections below.\n\n\n\n## How to Use This Skill (AI Meta-Guidance and Intent Decision Tree)\n\nWhen you (the AI) trigger and read this Skill, strictly follow this cognitive model and execution order:\n\n### 1. Intent Decision Tree\nIn the first second of receiving a task, classify which branch it belongs to:\n- **Branch A: Focused Quick Triage / Specific Function / Diff / Error Stack**\n - **Indicators**: Single-file inspection, reproducing a specific function, analyzing an exception stack trace.\n - **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!**\n- **Branch B: Full-Repository Vulnerability Hunting / Deep Mutation / Parallel Worker Audit**\n - **Indicators**: User explicitly triggers `/bugx`, requests \"full codebase audit\", or \"hunt deep vulnerabilities\".\n - **Action**: Follow the canonical lifecycle progression (`engine pre` -> gate confirmation -> Explore -> Mutate -> Repair -> post settlement).\n- **Branch C: Environment Diagnosis / Dependency Repair / Host Inspection**\n - **Action**: Run `bugx doctor --root <ROOT> --json` and `bugx engine --root <ROOT> status --json`; never use `init` or `--force` blindly.\n\n### 2. Standard 5-Step Execution Loop\n1. **Target Root**: Confirm the target repository's absolute path `<ROOT>`; strictly restrict operations within `<ROOT>`, and forbid broad filesystem scans.\n2. **Inspect State**: Run read-only commands to check runtime state first (`bugx engine --root <ROOT> status --json` or `bugx doctor`).\n3. **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.\n4. **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.\n5. **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).\n\n### 3. Core Action Matrix (High-Frequency Commands Covering 90% of Calls)\n- **Environment Diagnosis**: `bugx doctor --root <ROOT> --json` (`--repair-assets` for repair)\n- **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.\n- **Reproduction and Mutation**: `bugx test-generate --root <ROOT> --scope <PATH::SYM> --out <FILE>` / `bugx test-verify verify --scope <SCOPE>`\n- **Supervisor and Concurrency**: `bugx supervisor status --root <ROOT>`\n- **Telemetry and Logs**: `bugx telemetry inspect` / `bugx log --root <ROOT> --errors`\n- **Dual Reports and Preview**: `bugx report both --eval-dir verification/evals/oss --out verification/evals/oss` / `bugx report serve --port 18991`\n\n### 4. Compact Command Radar (41 Top-level Commands Classified Index)\nTo invoke any command below, inspect exact parameters dynamically via `bugx help <cmd>`; never guess:\n- **Diagnostics and Inspection (9)**: `help`, `doctor`, `hosts`, `completion`, `log`, `stats`, `view`, `project`, `self-audit`\n- **Core Lifecycle and Hosts (14)**: `init`, `engine`, `supervisor`, `daemon`, `config`, `reset`, `install`, `uninstall`, `dsh`, `plugin`, `mcp`, `mcp-runtime`, `capability`, `logic-analysis`\n- **Deep Audit and Verification (10)**: `audit`, `probe`, `test-generate`, `test-audit`, `test-verify`, `patch-forge`, `test-strategy`, `fuzz-input`, `differential-probe`, `mining-audit`\n- **Knowledge Flywheel and Delivery (8)**: `report`, `lesson`, `knowledge`, `skill`, `cloud`, `auth`, `telemetry`, `advisory`\n\n### 5. Mandatory Rules and Deprecated Command Redirection\n- **Gate Blockage Forbids Destructive Repairs**: `FATAL_BLOCKED` must never be bypassed using `init`, `reset`, or `--force`; preserve logs and state first.\n- **Deprecated Command Redirections**: `matrix` -> `bugx audit`; `console` -> `bugx report serve`; `watch` -> `bugx log --watch`; `test` is not a public command. For development checks, create a minimal temporary verification script outside the repository or run tests owned by the target project, then delete the process file.\n",
457
+ "host.entry.section.commands": "## Host Route (before intent triage)\n\n- **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.\n- All other hosts follow the sections below.\n\n\n\n## How to Use This Skill (AI Meta-Guidance and Intent Decision Tree)\n\nWhen you (the AI) trigger and read this Skill, strictly follow this cognitive model and execution order:\n\n### 1. Intent Decision Tree\nIn the first second of receiving a task, classify which branch it belongs to:\n- **Branch A: Focused Quick Triage / Specific Function / Diff / Error Stack**\n - **Indicators**: Single-file inspection, reproducing a specific function, analyzing an exception stack trace.\n - **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!**\n- **Branch B: Full-Repository Vulnerability Hunting / Deep Mutation / Parallel Worker Audit**\n - **Indicators**: User explicitly triggers `/bugx`, requests \"full codebase audit\", or \"hunt deep vulnerabilities\".\n - **Action**: Follow the canonical lifecycle progression (`engine pre` -> gate confirmation -> Explore -> Mutate -> Repair -> post settlement).\n- **Branch C: Environment Diagnosis / Dependency Repair / Host Inspection**\n - **Action**: Run `bugx doctor --root <ROOT> --json` and `bugx engine --root <ROOT> status --json`; never use `init` or `--force` blindly.\n\n### 2. Standard 5-Step Execution Loop\n1. **Target Root**: Confirm the target repository's absolute path `<ROOT>`; strictly restrict operations within `<ROOT>`, and forbid broad filesystem scans.\n2. **Inspect State**: Run read-only commands to check runtime state first (`bugx engine --root <ROOT> status --json` or `bugx doctor`).\n3. **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.\n4. **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.\n5. **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).\n\n### 3. Core Action Matrix (High-Frequency Commands Covering 90% of Calls)\n- **Live Guide Lookup**: `bugx guide \"<keyword>\"` (queries synced official docs and project docs; pass `--offline` for airgap environments)\n- **Environment Diagnosis**: `bugx doctor --root <ROOT> --json` (`--repair-assets` for repair)\n- **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.\n- **Reproduction and Mutation**: `bugx test-generate --root <ROOT> --scope <PATH::SYM> --out <FILE>` / `bugx test-verify verify --scope <SCOPE>`\n- **Supervisor and Concurrency**: `bugx supervisor status --root <ROOT>`\n- **Telemetry and Logs**: `bugx telemetry inspect` / `bugx log --root <ROOT> --errors`\n- **Dual Reports and Preview**: `bugx report both --eval-dir verification/evals/oss --out verification/evals/oss` / `bugx report serve --port 18991`\n\n### 4. Compact Command Radar (43 Top-level Commands Classified Index)\nTo invoke any command below, inspect exact parameters dynamically via `bugx help <cmd>`; never guess:\n- **Diagnostics and Inspection (10)**: `help`, `completion`, `guide`, `hosts`, `doctor`, `log`, `stats`, `view`, `project`, `self-audit`\n- **Core Lifecycle and Hosts (15)**: `init`, `install`, `reset`, `uninstall`, `dsh`, `engine`, `supervisor`, `daemon`, `config`, `plugin`, `mcp`, `capability`, `mcp-runtime`, `update`, `interaction`\n- **Deep Audit and Verification (10)**: `audit`, `probe`, `logic-analysis`, `mining-audit`, `test-generate`, `test-audit`, `test-verify`, `patch-forge`, `autonomous`, `goal`\n- **Cloud, Knowledge, and Delivery (8)**: `cloud`, `auth`, `telemetry`, `knowledge`, `lesson`, `skill`, `advisory`, `report`\n\n### 5. Mandatory Rules and Deprecated Command Redirection\n- **Gate Blockage Forbids Destructive Repairs**: `FATAL_BLOCKED` must never be bypassed using `init`, `reset`, or `--force`; preserve logs and state first.\n- **Deprecated Command Redirections**: `matrix` -> `bugx audit`; `console` -> `bugx report serve`; `watch` -> `bugx log --watch`; `test` is not a public command. For development checks, create a minimal temporary verification script outside the repository or run tests owned by the target project, then delete the process file.\n",
458
458
  "host.entry.description.codex": "Codex-specific BugX operation Skill for starting, resuming and diagnosing BugX audits and reviewing local model and token usage. Preserve the complete Agent workflow, native user gates and evidence validation while dispatching native Workers for the actual project scope.",
459
459
  "prompt.plugin.chatgpt_shared_skill_write_failed": "Shared global Skill write failed (plugin registration unaffected): {error}",
460
460
  "exception.plugin.claude_usage_skill_missing": "Claude host manual skill is missing; installation cannot complete: {path}\nThis file is a mandatory load listed in bugx/SKILL.md, not an optional add-on.\nFix: ensure ecosystem/plugins/bugx/skills/bugx-claude/SKILL.md is tracked by git, then rebuild the wheel."
@@ -415,8 +415,8 @@
415
415
  "prompt.tier.default.description": "通用默认模型",
416
416
  "prompt.tier.explore.description": "高吞吐扫描模型 (Flash / Haiku / GPT-4o-mini),适用于大规模单元与路由勘察",
417
417
  "prompt.tier.gate.description": "快速轻量级模型 (Flash / Haiku / GPT-4o-mini),适用于快速门禁与基线核验",
418
- "prompt.tier.mutate.description": "深度推理模型 (Sonnet / DeepSeek-R1 / GPT-4o),适用于并发竞态、状态推演与差分验证",
419
- "prompt.tier.repair.description": "高精度工程代码模型 (Claude 3.5 Sonnet / Codex),适用于 TDD 最小修复与单测闭环",
418
+ "prompt.tier.mutate.description": "深度推理模型 (Claude Sonnet 5.5 / Gemini 4 Carbon / DeepSeek-R1 / GPT-4o),适用于并发竞态、状态推演与差分验证",
419
+ "prompt.tier.repair.description": "高精度工程代码模型 (Claude Sonnet 5.5 / Opus 5.5 / Codex),适用于 TDD 最小修复与单测闭环",
420
420
  "prompt.workers.shared_instruction_body": "你是 BugX 并发 worker。宿主已经原子预占了下面给你的 coverage unit(s);不要再次 claim。\n1. 先通过 `bugx engine path --name audit_supervisor.py` 定位全局脚本,再确认真实启动(返回的 execution_id 必须保持不变;只能逐字复制预占值,无法确认时省略,禁止生成/替换):\n <Python> <全局引擎>/audit_supervisor.py worker-start --root . \\\n --state {state_rel} --worker <预占 worker_id> --provider <provider>\n2. 对分配单元完成勘察 → 测试 → 证据复验;所有证据写入预占 claim 返回的 artifact_root。每个 coverage unit 必须使用独立且唯一的 artifact 文件;提交 checkpoint 后不得覆盖或修改。\n 没有宿主提供的独立 git worktree 时禁止修改共享源码,修复由宿主串行完成;\n 不写共享运行态、不写 life、不跑 verify_life.py settle、不生成最终报告。\n3. 提交 checkpoint(JSON 中 life_delta 必须是数字 0,不能写成字符串 \\\"0\\\";artifact_path 必须位于自己的 artifact_root):\n <Python> <全局引擎>/audit_supervisor.py checkpoint --root . \\\n --state {state_rel} --worker <预占 worker_id> --input <payload.json>\n payload.json 必须包含本次提交唯一且可重试的 checkpoint_id,覆盖所有领取的 units。expected_revision 只有在同一 MCP 响应刚返回该值时才能原样带上;否则省略,禁止猜测 0/1。\n coverage=covered 表示覆盖状态;evidence.status 必须填 passed(且 exit_code=0),其他证据状态只能是 failed/error/skipped/blocked,不能填 covered。每个 candidate finding 的 evidence 必须是对象列表 `[{{\"path\": \"<相对路径>\", \"line\": <正整数行号>}}]`,严禁写成 `path:line` 字符串。候选 finding 若 `reproducible=true`,必须同时填写非空 `reproduction`,内容应是可复现命令或步骤;没有复现步骤就不要标记为可复现。\n4. worker-start 成功后立即调用一次 bugx_supervisor_heartbeat(这是启动后的首个活性证明),此后每 ≤5 分钟一次;长命令(预计 >60s 的探针/测试)开始前先调用 bugx_supervisor_begin_long_call(expected_seconds≤1800,声明保活窗口防止租约在命令执行中被回收),窗口结束后每 5 分钟调用 bugx_supervisor_heartbeat;卡住由宿主回收租约,不要把普通 claim 当成真实执行,也不要调用项目 `.bugx/core` 入口。\n4a. checkpoint 被拒(run_id/execution_receipt/跨纪元证据)时,把探针输出重写到 artifact_root 下的新文件,再用步骤 3 的收尾器(worker_checkpoint.py finalize)按当前纪元重建合规 checkpoint,勿盲目重跑探针。",
421
421
  "prompt.workers.shared_instruction_header": "【共享指令】把下面这段粘进每个 worker 的 Task 提示词:",
422
422
  "prompt.workers.task_harness_banner": " [主动注入 Stage Harness 任务包]:",
@@ -454,7 +454,7 @@
454
454
  "host.entry.body.qoder_worker": "\n# BugX Worker — Qoder 并发 Worker 子智能体\n\n你是 BugX 的并发 worker 子智能体,由主 Agent 通过 Qoder 的 subagent 能力(`subagent_type=bugx-worker`)在 Round 内并发派发。先通过 `bugx engine path --name <文件>` 读取并遵守以下全局引擎协议;它们是唯一权威实体,本入口不复制其内容:\n\n- `bugx engine path --name bugx-worker.md`:worker 单元级执行规则(开工四步、挖掘纪律、立案 oracle、证据硬门槛、checkpoint 提交);\n- `bugx engine path --name bugx-runtime-contract.md` 与 `bugx engine path --name bugx-quick.md`:寿命、Supervisor、证据和报告协议。\n\n上述文件由全局引擎提供,不检查项目 `.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 不运行主控初始化或安装命令,也不在布局缺失时执行协议步骤。\n\n## Worker 角色边界(强制)\n\n- 只负责 Supervisor 分配给你的覆盖单元或亲和任务包:`claim`(宿主已预占时跳过)→ `worker-start` → 挖掘举证 → `checkpoint`;`life_delta` 必须为 0,不写寿命、不结算、不生成最终报告、不领取清单外的单元。\n- 只能使用 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`。\n- 证据只能写入 claim 返回的 `artifact_root`,越界路径会被 Supervisor 拒绝;没有派发方明确提供独立 git worktree 时,不得修改共享工作树源码,修复由宿主串行完成。\n- 长命令期间每 5 分钟补一次 heartbeat;返回非零或 `CONTROL_PAUSED`/`CONTROL_ABORTED` 时,停在安全边界并把状态报告给派发方。\n\n## Qoder Worker 交互适配(强制)\n\nWorker 是子智能体,不呈现任何启动门禁,也不得调用 `AskUserQuestion`——常规启动由项目配置自动决策,不发起串行启动问卷。确需用户决策时,直接结束并把 `BUGX_INTERACTION_REQUEST <json>` 原文报告给派发方,不得自行作答或猜选项。Worker 自身按非 TTY 处理:只转发当前一个单选请求,答案由派发方回传后再继续。\n",
455
455
  "plugin.zcode_plugin_boundary": "## 用户级插件边界(插件形态专用)\n\n本入口以 ZCode 插件(agent 命名 `{agent_ref}`)注册,可跨项目使用。操作项目前先运行只读命令 `bugx engine --root . status --json`:仅当返回 `UNINITIALIZED` 时,才运行 `bugx engine --root . pre` 安全准备新项目;返回 `FATAL_BLOCKED`、其他阻断状态或检查失败时,保留数据并停止,严禁用 `bugx init`、`bugx reset` 或 `--force` 绕过。本入口不能替代全局引擎载荷。\n",
456
456
  "plugin.chatgpt_skill_banner": "这是 BugX 的 ChatGPT Skill 镜像。执行前通过 `bugx engine path --name AGENT_GUIDE.md` 和 `bugx engine path --name bugx.md` 读取全局协议;全局引擎是协议和运行时的唯一权威来源。\n\n协议镜像版本:{version}\n",
457
- "host.entry.section.commands": "## 宿主路由(先于意图分流)\n\n- **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。\n- 其余宿主按后续章节执行。\n\n\n\n## 如何使用本技能(AI 执行元指南与意图决策树)\n\n当你(AI)触发并阅读本技能时,请无条件遵循以下认知模型与执行时序:\n\n### 1. 意图决策树(Triage Decision Tree)\n拿到任务第一秒,判定属于哪个分支:\n- **分支 A:单点敏捷排查 / 特定函数 / Diff / 报错堆栈**\n - **标志**:单文件排查、复现某个函数、分析异常报错。\n - **动作**:就地编写轻量复现脚本(PoC)或运行定向测试,使用 `bugx view`, `bugx test-generate`, `bugx test-verify`;**严禁启动重型全流程门禁!**\n- **分支 B:全库漏洞挖掘 / 深度变异 / 多 Worker 并发审计**\n - **标志**:用户明确输入 `/bugx`、要求“全库审计”、“挖掘潜在漏洞”。\n - **动作**:按标准生命周期流转(`engine pre` -> 门禁确认 -> Explore -> Mutate -> Repair -> 结算)。\n- **分支 C:环境诊断 / 依赖修复 / 宿主状态排查**\n - **动作**:优先运行 `bugx doctor --root <ROOT> --json` 与 `bugx engine --root <ROOT> status --json`,绝不盲目 `init` 或 `--force`。\n\n### 2. 标准五步操作闭环(5-Step Execution Loop)\n1. **定根**:确定被测项目根绝对路径 `<ROOT>`,严格在 `<ROOT>` 内部执行,禁止全盘发散扫描。\n2. **探况**:先执行只读命令检查运行态(`bugx engine --root <ROOT> status --json` 或 `bugx doctor`)。\n3. **选路**:根据意图挑选命令;若需查阅参数,运行 `bugx help <顶层命令>`(如 `bugx help cloud`)按需动态读取,严禁盲猜。\n4. **承接**:若 `engine pre` 返回退出码 `2`,表示等待宿主单选门禁交互;必须调用宿主原生控件展示选项,按用户选择的 action 执行,禁止文本伪造选择或自旋重试。退出码 `0` 只代表门禁通过,不代表挖掘完成。\n5. **闭环**:缺陷必须给出最小独立复现脚本(PoC)与完整调用栈证据;使用 6 大标准汇报用词(只读检查、项目就绪、门禁就绪、测试执行、挖掘启动、挖掘完成)如实汇报。\n\n### 3. 高频场景命令(覆盖 90% 日常调用)\n- **环境诊断**:`bugx doctor --root <ROOT> --json`(`--repair-assets` 按需修复)\n- **启动与门禁**:先运行 `bugx engine --root <ROOT> status --json`;仅当状态为 `UNINITIALIZED` 时运行 `bugx engine --root <ROOT> pre` 自动准备新项目。挖掘启动不要先调用 `bugx init`;它是独立 CLI 初始化操作,不替代 status/pre 状态机。若状态为 `FATAL_BLOCKED`、其他阻断状态或检查失败,保留现场并停止;禁止用 `init`、`reset` 或 `--force` 绕过门禁。\n- **单点复现与变异**:`bugx test-generate --root <ROOT> --scope <PATH::SYM> --out <FILE>` / `bugx test-verify verify --scope <SCOPE>`\n- **Supervisor 与并发排查**:`bugx supervisor status --root <ROOT>`\n- **脱敏飞轮与日志**:`bugx telemetry inspect` / `bugx log --root <ROOT> --errors`\n- **双轨报告与预览**:`bugx report both --eval-dir verification/evals/oss --out verification/evals/oss` / `bugx report serve --port 18991`\n\n### 4. 紧凑型命令全景雷达(41 个顶层命令分类索引)\n如需调用以下命令,通过 `bugx help <命令>` 动态获取具体参数与子命令,严禁盲猜:\n- **诊断探索 (9)**:`help`, `doctor`, `hosts`, `completion`, `log`, `stats`, `view`, `project`, `self-audit`\n- **核心生命周期 (14)**:`init`, `engine`, `supervisor`, `daemon`, `config`, `reset`, `install`, `uninstall`, `dsh`, `plugin`, `mcp`, `mcp-runtime`, `capability`, `logic-analysis`\n- **深度审计验证 (10)**:`audit`, `probe`, `test-generate`, `test-audit`, `test-verify`, `patch-forge`, `test-strategy`, `fuzz-input`, `differential-probe`, `mining-audit`\n- **知识飞轮交付 (8)**:`report`, `lesson`, `knowledge`, `skill`, `cloud`, `auth`, `telemetry`, `advisory`\n\n### 5. 核心军规与废弃命令重定向\n- **阻断不授权暴力修复**:`FATAL_BLOCKED` 严禁使用 `init`、`reset`、`--force` 绕过,先保留报告和日志。\n- **废弃命令重定向**:`matrix` -> `bugx audit`;`console` -> `bugx report serve`;`watch` -> `bugx log --watch`;`test` 不是公共命令。开发验证请在仓库外生成最小临时验证脚本,或运行被测目标项目自带的测试,完成后删除过程文件。\n",
457
+ "host.entry.section.commands": "## 宿主路由(先于意图分流)\n\n- **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。\n- 其余宿主按后续章节执行。\n\n\n\n## 如何使用本技能(AI 执行元指南与意图决策树)\n\n当你(AI)触发并阅读本技能时,请无条件遵循以下认知模型与执行时序:\n\n### 1. 意图决策树(Triage Decision Tree)\n拿到任务第一秒,判定属于哪个分支:\n- **分支 A:单点敏捷排查 / 特定函数 / Diff / 报错堆栈**\n - **标志**:单文件排查、复现某个函数、分析异常报错。\n - **动作**:就地编写轻量复现脚本(PoC)或运行定向测试,使用 `bugx view`, `bugx test-generate`, `bugx test-verify`;**严禁启动重型全流程门禁!**\n- **分支 B:全库漏洞挖掘 / 深度变异 / 多 Worker 并发审计**\n - **标志**:用户明确输入 `/bugx`、要求“全库审计”、“挖掘潜在漏洞”。\n - **动作**:按标准生命周期流转(`engine pre` -> 门禁确认 -> Explore -> Mutate -> Repair -> 结算)。\n- **分支 C:环境诊断 / 依赖修复 / 宿主状态排查**\n - **动作**:优先运行 `bugx doctor --root <ROOT> --json` 与 `bugx engine --root <ROOT> status --json`,绝不盲目 `init` 或 `--force`。\n\n### 2. 标准五步操作闭环(5-Step Execution Loop)\n1. **定根**:确定被测项目根绝对路径 `<ROOT>`,严格在 `<ROOT>` 内部执行,禁止全盘发散扫描。\n2. **探况**:先执行只读命令检查运行态(`bugx engine --root <ROOT> status --json` 或 `bugx doctor`)。\n3. **选路**:根据意图挑选命令;若需查阅参数,运行 `bugx help <顶层命令>`(如 `bugx help cloud`)按需动态读取,严禁盲猜。\n4. **承接**:若 `engine pre` 返回退出码 `2`,表示等待宿主单选门禁交互;必须调用宿主原生控件展示选项,按用户选择的 action 执行,禁止文本伪造选择或自旋重试。退出码 `0` 只代表门禁通过,不代表挖掘完成。\n5. **闭环**:缺陷必须给出最小独立复现脚本(PoC)与完整调用栈证据;使用 6 大标准汇报用词(只读检查、项目就绪、门禁就绪、测试执行、挖掘启动、挖掘完成)如实汇报。\n\n### 3. 高频场景命令(覆盖 90% 日常调用)\n- **手册即时检索**:`bugx guide \"<关键词>\"`(官方热点同步 + 本地项目文档检索;离线加 `--offline`)\n- **环境诊断**:`bugx doctor --root <ROOT> --json`(`--repair-assets` 按需修复)\n- **启动与门禁**:先运行 `bugx engine --root <ROOT> status --json`;仅当状态为 `UNINITIALIZED` 时运行 `bugx engine --root <ROOT> pre` 自动准备新项目。挖掘启动不要先调用 `bugx init`;它是独立 CLI 初始化操作,不替代 status/pre 状态机。若状态为 `FATAL_BLOCKED`、其他阻断状态或检查失败,保留现场并停止;禁止用 `init`、`reset` 或 `--force` 绕过门禁。\n- **单点复现与变异**:`bugx test-generate --root <ROOT> --scope <PATH::SYM> --out <FILE>` / `bugx test-verify verify --scope <SCOPE>`\n- **Supervisor 与并发排查**:`bugx supervisor status --root <ROOT>`\n- **脱敏飞轮与日志**:`bugx telemetry inspect` / `bugx log --root <ROOT> --errors`\n- **双轨报告与预览**:`bugx report both --eval-dir verification/evals/oss --out verification/evals/oss` / `bugx report serve --port 18991`\n\n### 4. 紧凑型命令全景雷达(43 个顶层命令分类索引)\n如需调用以下命令,通过 `bugx help <命令>` 动态获取具体参数与子命令,严禁盲猜:\n- **诊断与探索 (10)**:`help`, `completion`, `guide`, `hosts`, `doctor`, `log`, `stats`, `view`, `project`, `self-audit`\n- **核心生命周期与宿主 (15)**:`init`, `install`, `reset`, `uninstall`, `dsh`, `engine`, `supervisor`, `daemon`, `config`, `plugin`, `mcp`, `capability`, `mcp-runtime`, `update`, `interaction`\n- **深度审计与测试验证 (10)**:`audit`, `probe`, `logic-analysis`, `mining-audit`, `test-generate`, `test-audit`, `test-verify`, `patch-forge`, `autonomous`, `goal`\n- **云端、知识与交付 (8)**:`cloud`, `auth`, `telemetry`, `knowledge`, `lesson`, `skill`, `advisory`, `report`\n\n### 5. 核心军规与废弃命令重定向\n- **阻断不授权暴力修复**:`FATAL_BLOCKED` 严禁使用 `init`、`reset`、`--force` 绕过,先保留报告和日志。\n- **废弃命令重定向**:`matrix` -> `bugx audit`;`console` -> `bugx report serve`;`watch` -> `bugx log --watch`;`test` 不是公共命令。开发验证请在仓库外生成最小临时验证脚本,或运行被测目标项目自带的测试,完成后删除过程文件。\n",
458
458
  "host.entry.description.codex": "Codex 宿主专属 BugX 操作 Skill。用于在 Codex 中启动、恢复和排障 BugX 审计及读取本地模型与 Token 用量。保留完整 Agent 流程、原生用户门禁和证据校验;按项目规模分派真实原生 Worker。",
459
459
  "prompt.plugin.chatgpt_shared_skill_write_failed": "共享全局 Skill 写入失败(不影响插件注册):{error}",
460
460
  "exception.plugin.claude_usage_skill_missing": "Claude 宿主手册 Skill 缺失,无法完成安装:{path}\n该文件是 bugx/SKILL.md 要求的强制加载项,不属于可选增强件。\n修复:确认仓库内 ecosystem/plugins/bugx/skills/bugx-claude/SKILL.md 已纳入版本控制(git add),并重新构建 wheel。"
@@ -1259,7 +1259,7 @@ def handle_supervisor_run_sandboxed_probe(service: Any, arguments: Mapping[str,
1259
1259
  except Exception:
1260
1260
  pass
1261
1261
  stdout, stderr = proc.communicate()
1262
- exit_code = -signal.SIGKILL
1262
+ exit_code = -getattr(signal, "SIGKILL", 9)
1263
1263
  stderr = (stderr or "") + f"\n[timeout]: Command timed out after {timeout}s and process group was terminated."
1264
1264
  except Exception as exc:
1265
1265
  exit_code = 1
@@ -317,6 +317,12 @@ def _check_venv_shebang(
317
317
  first_line = handle.readline(4096)
318
318
  except OSError as exc:
319
319
  return f"入口无法读取: {entry_rel}({exc})"
320
+ if (
321
+ first_line.startswith(b"MZ")
322
+ or entry_path.suffix.lower() in (".exe", ".com", ".cmd", ".bat")
323
+ ):
324
+ # Windows PE 可执行二进制文件或脚本(由 Windows 原生加载执行,无 Unix 文本 shebang)
325
+ return None
320
326
  if not first_line.startswith(b"#!"):
321
327
  return f"入口缺少 shebang(pypi console script 必须有): {entry_rel}"
322
328
  interpreter = first_line[2:].strip().decode("utf-8", "replace")
@@ -171,7 +171,7 @@ def _uv_managed_python(minor_spec: str) -> str:
171
171
 
172
172
 
173
173
  def _interpreter_candidates(spec: str) -> list[tuple[str, str, str]]:
174
- """列出本机**可用且满足约束**的解释器:``(路径, 版本, 来源)``,按版本降序。"""
174
+ """列出本机**可用且满足约束**的解释器:``(路径, 版本, 来源)``,按优先级排序。"""
175
175
  normalized = _normalize_python_spec(spec)
176
176
  found: dict[str, tuple[str, str, str]] = {}
177
177
 
@@ -187,10 +187,43 @@ def _interpreter_candidates(spec: str) -> list[tuple[str, str, str]]:
187
187
  if ok:
188
188
  found[resolved] = (resolved, version, source)
189
189
 
190
- for major, minor in _allowed_minors(spec):
191
- on_path = shutil.which(f"python{major}.{minor}")
190
+ # 1. 优先使用当前正在运行 BugX 的解释器 (sys.executable)
191
+ if sys.executable:
192
+ consider(sys.executable, "host")
193
+
194
+ # 2. 检索 PATH 中的通用 Python 命令
195
+ for name in ("python", "python3", "python.exe", "python3.exe"):
196
+ on_path = shutil.which(name)
192
197
  if on_path:
193
198
  consider(on_path, "host")
199
+
200
+ # 3. 检索具体小版本命令 (python3.12, python3.13 等)
201
+ for major, minor in _allowed_minors(spec):
202
+ for name in (f"python{major}.{minor}", f"python{major}.{minor}.exe"):
203
+ on_path = shutil.which(name)
204
+ if on_path:
205
+ consider(on_path, "host")
206
+
207
+ # 4. Windows 常见官方与系统安装目录
208
+ if os.name == "nt":
209
+ local_app = os.environ.get("LOCALAPPDATA")
210
+ if local_app:
211
+ programs_py = Path(local_app) / "Programs" / "Python"
212
+ if programs_py.is_dir():
213
+ for candidate in sorted(programs_py.glob("Python3*")):
214
+ exe = candidate / "python.exe"
215
+ if exe.is_file():
216
+ consider(str(exe), "host")
217
+ roaming_app = os.environ.get("APPDATA")
218
+ if roaming_app:
219
+ uv_py = Path(roaming_app) / "uv" / "python"
220
+ if uv_py.is_dir():
221
+ for candidate in sorted(uv_py.glob("cpython-3.*")):
222
+ exe = candidate / "python.exe"
223
+ if exe.is_file():
224
+ consider(str(exe), "uv-managed")
225
+
226
+ # 5. pyenv 与 uv 目录 (POSIX 及通用)
194
227
  pyenv_root = Path(os.environ.get("PYENV_ROOT") or (Path.home() / ".pyenv"))
195
228
  versions_dir = pyenv_root / "versions"
196
229
  if versions_dir.is_dir():
@@ -207,8 +240,11 @@ def _interpreter_candidates(spec: str) -> list[tuple[str, str, str]]:
207
240
  if executable.is_file():
208
241
  consider(str(executable), "uv-managed")
209
242
 
210
- def sort_key(item: tuple[str, str, str]) -> tuple[int, ...]:
211
- return tuple(int(part) for part in item[1].split(".") if part.isdigit())
243
+ def sort_key(item: tuple[str, str, str]) -> tuple[int, tuple[int, ...]]:
244
+ # 优先使用本机宿主已有解释器 (host),避免无端触发外部工具多装一份
245
+ source_prio = 2 if item[2] == "host" else (1 if item[2] == "pyenv" else 0)
246
+ ver_tuple = tuple(int(part) for part in item[1].split(".") if part.isdigit())
247
+ return (source_prio, ver_tuple)
212
248
 
213
249
  return sorted(found.values(), key=sort_key, reverse=True)
214
250
 
@@ -216,10 +252,10 @@ def _interpreter_candidates(spec: str) -> list[tuple[str, str, str]]:
216
252
  def _resolve_env_python(env_id: str, spec: str | None) -> tuple[str, str, str]:
217
253
  """解析 pypi 环境使用的解释器;返回 ``(可执行路径, 'X.Y.Z', 来源)``。
218
254
 
219
- ``spec`` 可以是 **约束**(``">=3.12,<3.14"``)或 ``"3.12"``(前缀匹配),
255
+ ``spec`` 可以是 **约束**(``">=3.12"``)或 ``"3.12"``(前缀匹配),
220
256
  ``None`` ⇒ 引擎自身解释器。**不写死小版本**:在本机满足约束的解释器里挑
221
- **最高**的一个(3.13 可用就用 3.13),一个都没有才用 uv 自愈安装
222
- **约束允许的最高版本**,全部失败才 fail-closed。
257
+ 满足要求的本机解释器(优先使用 host 已有环境),没有才用 uv 自愈安装
258
+ 约束允许的版本,全部失败才 fail-closed。
223
259
 
224
260
  来源 ∈ ``{"host", "pyenv", "uv-managed"}`` 并写入安装报告,便于审计
225
261
  "解释器是主机自带的,还是引擎自愈获取的"。
@@ -236,7 +272,8 @@ def _resolve_env_python(env_id: str, spec: str | None) -> tuple[str, str, str]:
236
272
  allowed = allowed_fn(spec)
237
273
  uv_fn = _get_mr_attr("_uv_managed_python", _uv_managed_python)
238
274
  pyver_fn = _get_mr_attr("_python_version_of", _python_version_of)
239
- for major, minor in reversed(allowed):
275
+ uv_minors = [m for m in reversed(allowed) if m[1] <= 14] or list(reversed(allowed))
276
+ for major, minor in uv_minors:
240
277
  healed = uv_fn(f"{major}.{minor}")
241
278
  if healed:
242
279
  return healed, pyver_fn(healed), "uv-managed"
@@ -364,7 +401,12 @@ def _install_pypi_environment(
364
401
  python = executable
365
402
  venv_dir = _venv_dir(staging, env_id)
366
403
  _create_venv(venv_dir, python, python_spec)
367
- pip = _venv_bin_dir(staging, env_id) / "pip"
404
+ bin_dir = _venv_bin_dir(staging, env_id)
405
+ pip = bin_dir / ("pip.exe" if os.name == "nt" else "pip")
406
+ if not pip.is_file() and os.name == "nt":
407
+ alt_pip = bin_dir / "pip"
408
+ if alt_pip.is_file():
409
+ pip = alt_pip
368
410
  if not pip.is_file() or pip.is_symlink():
369
411
  raise McpRuntimeError(f"venv 未提供普通文件形式的 pip,拒绝受限安装: {pip}")
370
412
  command = [str(pip), "install", *PYPI_INSTALL_FLAGS, "-r", str(requirements)]
@@ -396,7 +438,11 @@ def _install_pypi_environment(
396
438
  bin_dir = _venv_bin_dir(staging, env_id)
397
439
  if bin_dir.is_dir():
398
440
  for candidate in sorted(bin_dir.iterdir()):
399
- if candidate.is_file() and os.access(candidate, os.X_OK):
441
+ is_exec = candidate.is_file() and (
442
+ os.access(candidate, os.X_OK)
443
+ or (os.name == "nt" and candidate.suffix.lower() in (".exe", ".cmd", ".bat"))
444
+ )
445
+ if is_exec:
400
446
  executable_rels.add(candidate.relative_to(staging).as_posix())
401
447
  # 字节码闸门必须在**计算文件树/哈希之前**落地并预编译,
402
448
  # 否则首次运行写入的 .pyc 会让 tree_hash 漂移、verify 永久失败。
@@ -436,7 +482,11 @@ def _install_bytecode_guard(staging: Path, env_id: str) -> Path:
436
482
  "sys.dont_write_bytecode = True\n",
437
483
  encoding="utf-8",
438
484
  )
439
- interpreter = _venv_bin_dir(staging, env_id) / "python"
485
+ interpreter = _venv_bin_dir(staging, env_id) / ("python.exe" if os.name == "nt" else "python")
486
+ if not interpreter.is_file() and os.name == "nt":
487
+ alt = _venv_bin_dir(staging, env_id) / "python"
488
+ if alt.is_file():
489
+ interpreter = alt
440
490
  for arguments, label in (
441
491
  (["-m", "py_compile", str(guard)], "闸门预编译"),
442
492
  (["-m", "compileall", "-q", str(venv_dir)], "整棵 venv 预编译"),
@@ -460,18 +510,26 @@ def _install_bytecode_guard(staging: Path, env_id: str) -> Path:
460
510
 
461
511
  def _resolve_pypi_entry(staging: Path, env_id: str, entry_name: str) -> str:
462
512
  """把 lock 声明的 console script 名解析为 venv 内相对路径(fail-closed)。"""
463
- candidate = _venv_bin_dir(staging, env_id) / entry_name
464
- if candidate.is_symlink() or not candidate.is_file():
465
- raise McpRuntimeError(
466
- f"pypi server 的 console script 缺失或非普通文件: "
467
- f"{VENV_DIRNAME}/{env_id}/bin/{entry_name}"
468
- )
469
- if not os.access(candidate, os.X_OK):
470
- raise McpRuntimeError(
471
- f"pypi server 的 console script 不可执行: "
472
- f"{VENV_DIRNAME}/{env_id}/bin/{entry_name}"
473
- )
474
- return candidate.relative_to(staging).as_posix()
513
+ bin_dir = _venv_bin_dir(staging, env_id)
514
+ candidates = [bin_dir / entry_name]
515
+ if os.name == "nt" or sys.platform == "win32":
516
+ candidates.extend([
517
+ bin_dir / f"{entry_name}.exe",
518
+ bin_dir / f"{entry_name}.cmd",
519
+ bin_dir / f"{entry_name}.bat",
520
+ ])
521
+ for candidate in candidates:
522
+ if candidate.is_file() and not candidate.is_symlink():
523
+ if os.name != "nt" and not os.access(candidate, os.X_OK):
524
+ raise McpRuntimeError(
525
+ f"pypi server 的 console script 不可执行: "
526
+ f"{VENV_DIRNAME}/{env_id}/{bin_dir.name}/{candidate.name}"
527
+ )
528
+ return candidate.relative_to(staging).as_posix()
529
+ raise McpRuntimeError(
530
+ f"pypi server 的 console script 缺失或非普通文件: "
531
+ f"{VENV_DIRNAME}/{env_id}/{bin_dir.name}/{entry_name}"
532
+ )
475
533
 
476
534
 
477
535
  def _check_venv_shebang(
@@ -489,6 +547,12 @@ def _check_venv_shebang(
489
547
  first_line = handle.readline(4096)
490
548
  except OSError as exc:
491
549
  return f"入口无法读取: {entry_rel}({exc})"
550
+ if (
551
+ first_line.startswith(b"MZ")
552
+ or entry_path.suffix.lower() in (".exe", ".com", ".cmd", ".bat")
553
+ ):
554
+ # Windows PE 可执行二进制文件或脚本(由 Windows 原生加载执行,无 Unix 文本 shebang)
555
+ return None
492
556
  if not first_line.startswith(b"#!"):
493
557
  return f"入口缺少 shebang(pypi console script 必须有): {entry_rel}"
494
558
  interpreter = first_line[2:].strip().decode("utf-8", "replace")
package/core/metadata.txt CHANGED
@@ -1,4 +1,4 @@
1
- bugx_version: "0.1.3"
1
+ bugx_version: "0.1.5"
2
2
  bugx_channel: "stable"
3
3
  bugx_marker: "stable"
4
4
  build_id: 1
@@ -1,6 +1,6 @@
1
1
  # BugX Planning & Slicing Engine (能力规划、领域路由、代码切片与仲裁流水线)
2
2
 
3
- > **版本契约**: `0.1.2` | **所属分层**: `Layer 2: 分析、切片与探测引擎`
3
+ > **版本契约**: `0.1.5` | **所属分层**: `Layer 2: 分析、切片与探测引擎`
4
4
  > **工程规范**: 参见 [`docs/02_architecture/05_ARCH_NOMENCLATURE_GUIDE.md`](../../docs/02_architecture/05_ARCH_NOMENCLATURE_GUIDE.md)
5
5
  > **守卫机制**: `scripts/verify_directory_indices.py` (100% 物理条目索引覆盖)
6
6
 
@@ -150,13 +150,13 @@ _STAGE_TIER_MAP: dict[str, dict[str, Any]] = {
150
150
  },
151
151
  "mutate": {
152
152
  "tier": "tier_2_deep_reasoning",
153
- "description": "深度推理模型 (Sonnet / DeepSeek-R1 / GPT-4o),适用于并发竞态、状态推演与差分验证",
153
+ "description": "深度推理模型 (Claude Sonnet 5.5 / Gemini 4 Carbon / DeepSeek-R1 / GPT-4o),适用于并发竞态、状态推演与差分验证",
154
154
  "allowed_actions": ["fuzz", "perturb", "differential_test", "race_detect", "test_verify"],
155
155
  "recommended_tools": ["bugx_test_verify", "bugx_test_mutate", "bugx_fuzz_input", "bugx_fuzz_concurrency", "bugx_fuzz_stateful"],
156
156
  },
157
157
  "repair": {
158
158
  "tier": "tier_3_precise_code",
159
- "description": "高精度工程代码模型 (Claude 3.5 Sonnet / Codex),适用于 TDD 最小修复与单测闭环",
159
+ "description": "高精度工程代码模型 (Claude Sonnet 5.5 / Opus 5.5 / Codex),适用于 TDD 最小修复与单测闭环",
160
160
  "allowed_actions": ["minimize_repro", "tdd_fix", "directed_test", "post_settle", "test_verify"],
161
161
  "recommended_tools": ["bugx_minimize_repro", "bugx_test_verify"],
162
162
  },
@@ -37,6 +37,8 @@ DEFAULT_IGNORES = frozenset({
37
37
  ".mypy_cache",
38
38
  ".bugx",
39
39
  ".DS_Store",
40
+ "artifacts",
41
+ ".tools",
40
42
  })
41
43
 
42
44
 
@@ -1,9 +1,8 @@
1
1
  #!/usr/bin/env python3
2
2
  """探测 codebase-memory-mcp 安装、版本和当前仓库索引状态。
3
3
 
4
- 它是功能拆分和业务链路的首选语义增强层,但不是全量覆盖的硬依赖:缺失或索引
5
- 异常返回 DEGRADED,调用方必须取得用户的回退决定;本地 symbol_index/project_graph
6
- 仍负责不漏文件、不漏配置资产的覆盖事实。审计必须在准备记录中保存本命令结果。
4
+ 它是 BugX 的必装核心代码图谱引擎:缺失或版本不匹配时必须直接安装修复,
5
+ 严禁静默降级或豁免放行;本地 symbol_index/project_graph 负责全量资产清单与交叉校验。
7
6
  """
8
7
 
9
8
  from __future__ import annotations
@@ -25,12 +24,14 @@ import re
25
24
  import signal
26
25
  import shutil
27
26
  import subprocess
27
+ import sys
28
+ import sysconfig
28
29
  from pathlib import Path
29
30
 
30
31
  if __package__:
31
- from ..runtime.tool_install_targets import OPTIONAL_TOOL_PACKAGE_SPECS
32
+ from ..runtime.tool_install_targets import REQUIRED_TOOL_PACKAGE_SPECS
32
33
  else:
33
- from core.runtime.tool_install_targets import OPTIONAL_TOOL_PACKAGE_SPECS
34
+ from core.runtime.tool_install_targets import REQUIRED_TOOL_PACKAGE_SPECS
34
35
 
35
36
  PROJECT_URL = "https://github.com/DeusData/codebase-memory-mcp"
36
37
  RELEASE_URL = f"{PROJECT_URL}/releases"
@@ -79,7 +80,7 @@ def _probe_environment() -> dict[str, str]:
79
80
 
80
81
 
81
82
  def _pinned_cli_version() -> str | None:
82
- spec = OPTIONAL_TOOL_PACKAGE_SPECS.get("codebase-memory", "").strip()
83
+ spec = REQUIRED_TOOL_PACKAGE_SPECS.get("codebase-memory", "").strip()
83
84
  match = re.fullmatch(r"codebase-memory-mcp==(?P<version>\d+(?:\.\d+){1,3})", spec)
84
85
  return match.group("version") if match else None
85
86
 
@@ -98,21 +99,34 @@ def _binary_candidates(
98
99
  """Return bounded, deduplicated candidates, preferring managed user bin dirs.
99
100
 
100
101
  A caller-supplied binary is an explicit selection and remains authoritative.
101
- Otherwise, inspect the configured uv/XDG executable directories before
102
+ Otherwise, inspect the configured BugX/uv/XDG executable directories before
102
103
  arbitrary PATH entries so an unrelated workspace binary cannot shadow the
103
104
  installed tool.
104
105
  """
105
106
  if binary:
106
107
  return [str(binary)], False
107
108
 
108
- home = Path(environment.get("HOME") or str(Path.home()))
109
+ home = Path(environment.get("HOME") or environment.get("USERPROFILE") or str(Path.home()))
110
+ scripts_dir = "Scripts" if os.name == "nt" else "bin"
111
+ bugx_tool_bin = str(home / ".bugx" / "tools" / "codebase-memory" / scripts_dir)
112
+ bugx_bin = str(home / ".bugx" / "bin")
113
+ python_scripts = None
114
+ try:
115
+ python_scripts = sysconfig.get_path("scripts")
116
+ except (KeyError, TypeError, ValueError):
117
+ python_scripts = None
118
+
109
119
  directories: list[str] = []
110
120
  for value in (
121
+ bugx_tool_bin,
122
+ bugx_bin,
111
123
  environment.get("UV_TOOL_BIN_DIR"),
112
124
  environment.get("XDG_BIN_HOME"),
113
125
  str(Path(environment["XDG_DATA_HOME"]).parent / "bin")
114
126
  if environment.get("XDG_DATA_HOME") else None,
115
127
  str(home / ".local" / "bin"),
128
+ str(Path(sys.executable).parent),
129
+ python_scripts,
116
130
  *environment.get("PATH", "").split(os.pathsep),
117
131
  ):
118
132
  if not value:
@@ -141,7 +155,7 @@ def _binary_candidates(
141
155
 
142
156
  def _resolve_binary(
143
157
  environment: dict[str, str], expected_version: str, binary: str | None = None,
144
- *, timeout_seconds: float = 10.0,
158
+ *, timeout_seconds: float = 30.0,
145
159
  ) -> tuple[str | None, str | None, list[dict[str, str]], bool]:
146
160
  """Find an executable whose strict ``--version`` output matches the pin."""
147
161
  candidates, truncated = _binary_candidates(environment, binary)
@@ -170,7 +184,7 @@ def resolve_compatible_binary(
170
184
  *, environment: dict[str, str] | None = None,
171
185
  expected_version: str | None = None,
172
186
  binary: str | None = None,
173
- timeout_seconds: float = 10.0,
187
+ timeout_seconds: float = 30.0,
174
188
  ) -> str | None:
175
189
  """Return only a CLI that reports the repository's exact pinned version."""
176
190
  environment = environment or _probe_environment()
@@ -321,7 +335,12 @@ def _unsupported_output_detail(stdout: str, stderr: str) -> str:
321
335
  )
322
336
 
323
337
 
324
- def inspect(root: Path, binary: str | None = None) -> dict:
338
+ def inspect(
339
+ root: Path,
340
+ binary: str | None = None,
341
+ *,
342
+ check_project_index: bool = True,
343
+ ) -> dict:
325
344
  root = root.resolve()
326
345
  environment = _probe_environment()
327
346
  checks: list[dict] = []
@@ -387,6 +406,8 @@ def inspect(root: Path, binary: str | None = None) -> dict:
387
406
  "expected": expected_version,
388
407
  },
389
408
  ))
409
+ if not check_project_index:
410
+ return _report(root, checks, version_text, None)
390
411
  projects_result, retry_note, transient = _list_projects_with_retry(executable, environment)
391
412
  if projects_result is None:
392
413
  checks.append({
@@ -528,14 +549,12 @@ def _report(root: Path, checks: list[dict], version: str | None,
528
549
  ready = all(check["ok"] for check in checks)
529
550
  return {
530
551
  "status": "READY" if ready else "DEGRADED",
531
- # required_check means the startup environment must inspect and report
532
- # this capability. required remains false because local enumeration is
533
- # a valid fallback for small/offline projects.
552
+ # 必装核心能力:缺失或版本不匹配时必须阻断修复,禁止降级放行。
534
553
  "required_check": True,
535
- "required": False,
554
+ "required": True,
536
555
  "recommended": True,
537
- "hard_dependency": False,
538
- "role": "semantic-graph-enhancement",
556
+ "hard_dependency": True,
557
+ "role": "semantic-graph-core",
539
558
  "required_for": [
540
559
  "functional-minimization",
541
560
  "business-flow-discovery",
@@ -552,8 +571,8 @@ def _report(root: Path, checks: list[dict], version: str | None,
552
571
  ),
553
572
  "project": project.get("name") if project else None,
554
573
  "checks": checks,
555
- "fallback": "symbol_index.py + project_graph.py",
556
- "install": f"pipx install --force {OPTIONAL_TOOL_PACKAGE_SPECS['codebase-memory']}",
574
+ "fallback": "symbol_index.py + project_graph.py(仅作辅助基线对照,不得替代必装组件)",
575
+ "install": f"pipx install --force {REQUIRED_TOOL_PACKAGE_SPECS['codebase-memory']}(或 bugx doctor --repair)",
557
576
  "configure": "codebase-memory-mcp install,然后重启 AI 编程工具并索引项目",
558
577
  "source": RELEASE_URL,
559
578
  }
@@ -564,14 +583,13 @@ def print_report(report: dict, as_json: bool = False) -> None:
564
583
  print(json.dumps(report, ensure_ascii=False, indent=2))
565
584
  return
566
585
  print(
567
- f"[{report['status']}] codebase-memory-mcp(环境必检;语义拆分首选,非全量硬依赖)"
586
+ f"[{report['status']}] codebase-memory-mcp(必装核心代码图谱;缺失时阻断,不做降级放行)"
568
587
  )
569
588
  for check in report["checks"]:
570
589
  print(f" {'✓' if check['ok'] else '!'} {check['name']}: {check['detail']}")
571
590
  if report["status"] != "READY":
572
- print(f" → 推荐:{report['install']}")
591
+ print(f" → 安装:{report['install']}")
573
592
  print(f" → 配置:{report['configure']}")
574
- print(f" → 本轮回退:{report['fallback']}")
575
593
 
576
594
 
577
595
  def main(argv: list[str] | None = None) -> int:
@@ -580,8 +598,9 @@ def main(argv: list[str] | None = None) -> int:
580
598
  parser.add_argument("--root", type=Path, default=Path.cwd())
581
599
  parser.add_argument("--json", action="store_true")
582
600
  parser.add_argument("--strict", action="store_true")
601
+ parser.add_argument("--installation-only", action="store_true")
583
602
  args = parser.parse_args(argv)
584
- report = inspect(args.root)
603
+ report = inspect(args.root, check_project_index=not args.installation_only)
585
604
  print_report(report, args.json)
586
605
  return 1 if args.strict and report["status"] != "READY" else 0
587
606
 
@@ -635,7 +654,7 @@ def run_static_degraded(root: Path, *, binary: str | None = None) -> dict:
635
654
  "findings": [],
636
655
  "evidence": evidence,
637
656
  "fallback": "symbol_index.py + project_graph.py(本地全量枚举,不依赖语义图谱)",
638
- "install": f"pipx install --force {OPTIONAL_TOOL_PACKAGE_SPECS['codebase-memory']}",
657
+ "install": f"pipx install --force {REQUIRED_TOOL_PACKAGE_SPECS['codebase-memory']}",
639
658
  "metadata": {
640
659
  "degraded_mode": "local_coverage_facts_only",
641
660
  "semantic_graph_available": False,
@@ -155,6 +155,7 @@ _MOBILE_SCAN_MAX_DIRS = 128
155
155
  _MOBILE_SCAN_SKIP_DIRS = frozenset({
156
156
  ".git", ".bugx", ".gradle", ".idea", "__pycache__", "node_modules",
157
157
  "build", "dist", "target", "vendor", "Pods", "DerivedData",
158
+ "artifacts", ".tools",
158
159
  })
159
160
 
160
161
 
@@ -55,12 +55,17 @@ def normalized_tool_environment(environ: Mapping[str, str] | None = None) -> dic
55
55
  """Return a child environment that can see common user tool locations."""
56
56
  environment = dict(os.environ if environ is None else environ)
57
57
  entries = [item for item in environment.get("PATH", "").split(os.pathsep) if item]
58
- candidates = [environment.get("BUGX_TOOL_PATH", "")]
58
+ scripts_dir = "Scripts" if os.name == "nt" else "bin"
59
+ candidates = [
60
+ environment.get("BUGX_TOOL_PATH", ""),
61
+ str(Path.home() / ".bugx" / "tools" / "codebase-memory" / scripts_dir),
62
+ str(Path.home() / ".bugx" / "bin"),
63
+ str(Path.home() / ".local" / "bin"),
64
+ ]
59
65
  if os.name != "nt":
60
66
  candidates.extend((
61
67
  "/opt/homebrew/bin", "/usr/local/bin",
62
68
  "/home/linuxbrew/.linuxbrew/bin",
63
- str(Path.home() / ".local" / "bin"),
64
69
  str(Path.home() / ".cargo" / "bin"),
65
70
  ))
66
71
  for candidate in candidates:
@@ -161,13 +166,11 @@ _BUILTIN_PROBES: tuple[ProbeDescriptor, ...] = (
161
166
  script="codebase_memory_probe.py",
162
167
  domain="knowledge",
163
168
  accepts_root=True,
164
- description="Codebase Memory MCP 图谱语义与知识索引探针",
169
+ description="Codebase Memory MCP 必装核心代码图谱探针",
165
170
  priority=30,
166
171
  lifecycle="preflight",
167
- # 加速器而非硬依赖:引擎自带 symbol_index/project_graph 回退
168
- # (``BUGX_USE_CODEBASE_MEMORY=0`` 是受支持运行模式),因此可经
169
- # 项目 ``tooling_exemptions`` 显式豁免;critical 能力不得豁免。
170
- critical=False,
172
+ # 必装核心组件:缺失或未就绪必须安装修复并阻断,禁止经 tooling_exemptions 豁免降级。
173
+ critical=True,
171
174
  ),
172
175
  ProbeDescriptor(
173
176
  name="pattern",
@@ -79,7 +79,7 @@ VERSION_FLAG = {"codeql": "version"}
79
79
  SKIP_DIRS = {
80
80
  ".git", ".bugx", ".venv", "venv", "node_modules", "__pycache__",
81
81
  "dist", "build", "target", ".tox", ".mypy_cache", ".pytest_cache",
82
- "vendor", "Pods", ".gradle", ".idea",
82
+ "vendor", "Pods", ".gradle", ".idea", "artifacts", ".tools",
83
83
  }
84
84
 
85
85
  #: 项目级忽略文件名(放在项目根,gitignore 语法)。
@@ -29,7 +29,7 @@ from typing import Any, Mapping
29
29
  SKIP_DIRS = {
30
30
  ".git", ".bugx", ".venv", "venv", "node_modules", "__pycache__",
31
31
  "dist", "build", "target", ".tox", ".mypy_cache", ".pytest_cache",
32
- "vendor", "Pods", ".gradle", ".idea", ".dart_tool",
32
+ "vendor", "Pods", ".gradle", ".idea", ".dart_tool", "artifacts", ".tools",
33
33
  }
34
34
 
35
35
  LOCK_FILES = {