bugx-cli 0.1.1__py3-none-any.whl
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.
- bugx_cli/__init__.py +6 -0
- bugx_cli/cli.py +1685 -0
- bugx_cli/commands/__init__.py +1 -0
- bugx_cli/commands/advisory.py +94 -0
- bugx_cli/commands/agent.py +4210 -0
- bugx_cli/commands/audit.py +632 -0
- bugx_cli/commands/autonomous.py +260 -0
- bugx_cli/commands/cloud.py +1371 -0
- bugx_cli/commands/daemon.py +50 -0
- bugx_cli/commands/doctor.py +1590 -0
- bugx_cli/commands/goal.py +107 -0
- bugx_cli/commands/interaction.py +248 -0
- bugx_cli/commands/knowledge.py +619 -0
- bugx_cli/commands/lifecycle.py +2763 -0
- bugx_cli/commands/patch.py +1014 -0
- bugx_cli/commands/plugin.py +2749 -0
- bugx_cli/commands/plugin_claude.py +1446 -0
- bugx_cli/commands/plugin_cline.py +269 -0
- bugx_cli/commands/plugin_codex.py +74 -0
- bugx_cli/commands/plugin_funide.py +729 -0
- bugx_cli/commands/plugin_qoder.py +216 -0
- bugx_cli/commands/plugin_zcode.py +710 -0
- bugx_cli/commands/project.py +670 -0
- bugx_cli/commands/report.py +256 -0
- bugx_cli/commands/skill.py +251 -0
- bugx_cli/commands/stats.py +133 -0
- bugx_cli/commands/system.py +2567 -0
- bugx_cli/common.py +906 -0
- bugx_cli/host_adapters.py +1892 -0
- bugx_cli/hosts/__init__.py +80 -0
- bugx_cli/hosts/base.py +99 -0
- bugx_cli/hosts/registry.py +573 -0
- bugx_cli/hosts/template_engine.py +188 -0
- bugx_cli/infra/__init__.py +209 -0
- bugx_cli/infra/ai_advisor.py +851 -0
- bugx_cli/infra/engine_installer.py +1945 -0
- bugx_cli/infra/host_sync.py +548 -0
- bugx_cli/infra/mcp_advisor.py +826 -0
- bugx_cli/infra/security.py +339 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/bugx-mcp-manifest.json +53 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/CATALOG.json +141 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/README.md +254 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/README.md +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/android-interaction.json +81 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/android.json +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/desktop-macos.json +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/ios-interaction.json +34 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/ios.json +23 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/memory-macos.json +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/README.md +51 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/__init__.py +146 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_artifacts.py +766 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_eval.py +1155 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_execution.py +718 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_orchestrator.py +1351 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_targets.py +877 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_workspace.py +770 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/feature_baseline.py +150 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/README.md +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/LICENSE-3RD-PARTY.txt +66 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/LICENSE.txt +362 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/UPSTREAM.md +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/axe.min.js +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar-1024.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar-512.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar-tight.svg +23 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar.svg +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-cn.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-en.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-en.svg +74 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-zh.svg +74 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/codex.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/dsh.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/project-layout.md +42 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/zcode.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/README.md +37 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/manifest.json +94 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/00-scope.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/10-schema-inventory.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/20-query-and-integrity.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/80-evidence-regression.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/manifest.json +123 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/00-scope.md +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/10-process-model.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/20-package-integrity.md +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/30-ui-behavior.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/80-evidence-regression.md +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/memory-testing.md +227 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/manifest.json +155 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/android.md +19 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/h5.md +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/ios.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/miniprogram.md +26 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/webview.md +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/00-scope.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/10-platform-inventory.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/20-masvs-static.md +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/30-component-exposure.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/40-device-behavior.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/80-evidence-regression.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/manifest.json +127 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/00-scope.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/10-static-white-box.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/20-memory-concurrency.md +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/30-behavior-black-box.md +39 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/80-evidence-regression.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/platform-testing.md +174 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/manifest.json +191 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/graphql.md +5 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/h5.md +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/multi-tenant.md +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/oauth.md +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/upload.md +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/websocket.md +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/00-scope.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/10-discovery.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/20-auth-session.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/30-authz-business.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/40-input-output.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/50-state-async.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/60-file-ssrf-deser.md +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/70-config-dependency.md +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/80-evidence-regression.md +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/INTERFACE.md +61 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/README.md +58 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/__init__.py +109 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/attack_graph.py +1096 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/attack_graph_store.py +1868 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/audit_campaign.py +1232 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/behavior_graph.py +465 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/ghsa_advisories.py +174 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/models.py +93 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/mutator.py +87 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/patcher.py +126 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/scout.py +278 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/synthesizer.py +207 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/verifier.py +103 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/bugx.md +1299 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/bugx_paths.py +1881 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cli-help.txt +66 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/INTERFACE.md +32 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/README.md +62 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/__init__.py +23 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/auto_sync.py +398 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/cloud_client.py +1218 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/cloud_onboard.py +743 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/cloud_schema.py +648 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/consent.py +81 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/device_identity.py +307 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/endpoint_router.py +415 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/flywheel_client.py +769 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/network_transport.py +296 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/onboard_wizard.py +493 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/sensitive_filter.py +285 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/sync_pull.py +695 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/sync_push.py +723 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/AGENT_GUIDE.md +359 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/README.md +34 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-blackbox.md +541 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-opencode.md +469 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-quick.md +44 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-runtime-contract.md +353 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-worker.md +470 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/engine_gap_contracts.py +473 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/README.md +70 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/__init__.py +106 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_ai_review.py +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_backfill.py +54 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_bootstrap.py +713 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_business.py +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_cli.py +715 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_discovery.py +1429 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_evidence.py +1024 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_forensics.py +124 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_gate.py +277 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_intelligence.py +734 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_manifest.py +396 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_platform.py +77 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_validate.py +241 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/module_coverage.py +157 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/INTERFACE.md +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/README.md +21 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/__init__.py +5 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/interaction_preset.py +408 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/engine-integrity.json +2797 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/README.md +49 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/__init__.py +82 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/concurrency_fuzzer.py +435 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/differential_oracle.py +1164 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/fuzz_input.py +1291 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/stateful_fuzzer.py +404 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/README.md +61 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/__init__.py +130 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/capacity_planner.py +124 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/dependency_lock.py +317 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/goal_governor.py +754 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/guide_budget.py +458 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/lockdown.sh +50 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/readonly_enforcer.py +154 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/runtime_tool_gate.py +373 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/secret_redactor.py +784 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/token_budget.py +38 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/INTERFACE.md +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/README.md +51 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/__init__.py +121 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/base.py +111 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/claude.py +99 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/cline.py +298 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/codex.py +300 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/dsh.py +106 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/opencode.py +209 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/pi.py +94 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/zcode.py +99 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/INTERFACE.md +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/README.md +62 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/__init__.py +21 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/adapters.py +412 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/autonomous_runner.py +1152 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/cline.py +448 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/common.py +103 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/free_models.py +786 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_bootstrap.py +389 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_evaluators.py +761 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_probe.py +41 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_provider_arbitrator.py +831 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_registry.py +662 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_usage.py +127 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/mcp_process_tracker.py +509 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/mcp_registry_gate.py +379 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/pi.py +102 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/provider_facts.py +66 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/INTERFACE.md +51 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/README.md +67 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/__init__.py +140 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_base_usage.py +152 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_codex_usage.py +297 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_dsh_usage.py +184 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_mcp_toml.py +365 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_zcode_usage.py +269 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/base.py +479 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/claude.py +212 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/cline.py +229 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/codex.py +1006 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/dsh.py +526 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/opencode.py +358 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/pi.py +308 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/zcode.py +219 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/i18n.py +252 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/README.md +41 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/__init__.py +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/build_info.py +105 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/client_metadata.py +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/json_utils.py +22 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/python_runtime.py +540 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/safe_xml.py +221 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_bugx.py +118 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/INTERFACE.md +31 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/README.md +106 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/__init__.py +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/candidate_revalidation.py +484 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/common.py +1060 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/finding_confirm_phase.py +391 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/finding_settlement.py +1432 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/findings_adjudication.py +666 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/findings_snapshot.py +357 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/judge_phase.py +848 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/lesson_context.py +536 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/lifecycle_reporter.py +627 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/orchestrator_controls.py +686 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_commit.py +567 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_coverage_sync.py +598 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_dry_run.py +817 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_observability.py +367 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_phase.py +1223 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_receipt.py +373 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_round_lifecycle.py +786 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/pre_phase.py +1029 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/pre_recon_scout.py +879 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/pre_state_builder.py +1133 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/report_sharing.py +414 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/round_orchestrator.py +1116 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/session_runtime.py +1670 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/startup_gates.py +1050 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/startup_interaction.py +1003 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/startup_version_gate.py +879 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/supervisor_bridge.py +1253 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/supervisor_coverage.py +423 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/supervisor_degraded.py +1211 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/worker_barriers.py +424 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/worker_orchestrator.py +1246 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/worker_prior.py +749 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/INTERFACE.md +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/README.md +160 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/__init__.py +67 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/_facade.py +227 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/archive_ops.py +630 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/auto_materialization.py +459 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/bug-log.md +22 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/cli.py +275 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/export_ops.py +554 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_confirmation.py +1316 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_io.py +299 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_lifecycle.py +730 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_verification.py +405 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/incidents.py +1005 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/lesson-replay-cases.json +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/lesson_ledger.py +241 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/lesson_replay.py +272 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/life_ledger.py +668 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/mistake-book.md +130 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/patterns.py +684 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/receipt_contract.py +269 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/schema.py +1192 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/sync_ops.py +940 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/tool_experience.py +683 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/verify_life.py +1597 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/lesson-ledger.json +275 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/locales/README.md +19 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/locales/en-US.json +462 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/locales/zh-CN.json +462 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/INTERFACE.md +75 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/README.md +62 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/__init__.py +128 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/base.py +717 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/channel_lifecycle.py +751 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/graph_handlers.py +222 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/knowledge_handlers.py +536 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/mining_handlers.py +586 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/resource_prompt_table.py +116 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/retrieval_handlers.py +249 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/rpc_server.py +470 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/supervisor_handlers.py +1461 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/telemetry_handlers.py +227 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/tool_table.py +1030 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/README.md +21 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/__init__.py +1 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/common.py +363 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/environment.py +567 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/verifier.py +758 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/metadata.txt +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/README.md +157 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/__init__.py +242 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/capability_plan.py +187 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/capability_planner.py +195 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/domain_archetype.py +542 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/domain_router.py +269 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/dynamic_flow_analyzer.py +533 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/impact_pruner.py +435 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/intent_adjudicator.py +175 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/judge_pipeline.py +1246 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/logic_analysis.py +419 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/prompt_harness.py +1704 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/source_inspector.py +267 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/spec_harvester.py +449 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/target_sandbox_manager.py +573 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/test_capability_verifier.py +1364 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/tools-kb.md +38 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/unit_kind.py +122 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/INTERFACE.md +83 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/README.md +51 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/SPEC.md +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/__init__.py +76 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/android_probe.py +552 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/base.py +147 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/codebase_memory_probe.py +647 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/desktop_probe.py +342 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/differential_probe.py +434 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/efficiency_probe.py +232 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ios_binary_probe.py +472 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/memory_probe.py +392 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/miniprogram_probe.py +385 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/mobile_probe.py +466 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/native_probe.py +302 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/openwiki_probe.py +263 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/pattern_probe.py +453 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/platform_probe.py +424 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/probe_registry.py +1770 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sast_fixture_corpus.py +340 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sast_probe.py +1510 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sast_rules.py +1481 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sca_scanner.py +779 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_accessibility.py +149 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_audit.py +513 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_contract.py +273 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_evidence.py +212 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_measurements.py +314 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_repair.py +250 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_review.py +133 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_storybook.py +107 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_tokens.py +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_visual_diff.py +131 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/web_probe.py +714 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/INTERFACE.md +62 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/README.md +53 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/SPEC.md +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/__init__.py +201 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/arbitrator.py +316 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/constants.py +247 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/detector.py +399 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/extractors.py +836 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/fingerprint.py +116 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/storage.py +258 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/strategy.py +301 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/README.md +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/codex_dialog_dispatch.md +9 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/command_routing_en.md +42 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/command_routing_zh.md +42 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/l0_router.md +47 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/anti_patterns.md +16 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/concurrency_rules.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/memory_leak_rules.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/prompt_injection_defense.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_explore.md +31 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_gate.md +43 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_mutate.md +42 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_repair.md +85 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/README.md +74 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/__init__.py +169 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/fix_watchlist.py +391 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/l7_dynamic.py +418 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/l7_repair_loop.py +462 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/l7_selfcheck.py +862 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/minimize_repro.py +466 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/patch_synthesizer.py +617 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/regression_pack.py +379 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_fixer.py +910 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_loop.py +311 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_repair.py +348 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_rounds.py +212 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_scope.py +281 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/self_heal.py +604 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/test_generator.py +1108 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/test_quality_auditor.py +410 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/test_strategy.py +511 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/INTERFACE.md +59 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/README.md +69 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/SPEC.md +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/__init__.py +47 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/attestation.py +228 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/authority.py +255 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/finding_report.py +418 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/formal_report_builder.py +924 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/html_renderers.py +696 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/models.py +759 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/pdf_exporter.py +231 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/projects_assets.py +730 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/report_client.py +743 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/report_data_builder.py +388 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/report_share.py +459 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/sast_bridge.py +116 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/server.py +832 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/visual_report_builder.py +796 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/web-conformance.md +168 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/web_conformance.py +428 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/workbench_assets.py +484 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/INTERFACE.md +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/README.md +161 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/__init__.py +3 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/code_analyzer.py +1720 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/codebase_memory_bridge.py +337 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/context_assembler.py +240 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/corpus_fetch.py +369 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/graph_ego.py +597 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/knowledge_auto.py +662 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/knowledge_sources.py +168 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/knowledge_sync.py +1003 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/memory_store.py +480 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/query_planner.py +1020 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/rrf_engine.py +137 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/slice_extractor.py +1209 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/slice_normalizer.py +373 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/slice_spec.py +357 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/symbol_index.py +1151 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/universal_code_matcher.py +622 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/xerj_bridge.py +476 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/xerj_supervisor.py +362 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/README.md +33 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/PROVENANCE.json +30 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/crypto.yaml +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/network.yaml +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/resilience.yaml +47 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/storage.yaml +48 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/LICENSE +173 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/PROVENANCE.json +270 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-asymmetric-key-pair-used-for-multiple-purposes.yml +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-backup-manifest.yml +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-event-bound.yml +49 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-invalidated-enrollment.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-no-confirmation-required.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-validity-duration.yml +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-broken-encryption-algorithms.yaml +9 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-broken-encryption-modes.yaml +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-content-provider-exported.yml +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-custom-deeplink-scheme.yml +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-dangerous-app-permissions.yaml +65 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-data-unencrypted-shared-storage-no-user-interaction-apis.yml +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-data-unencrypted-shared-storage-no-user-interaction-manifest.yml +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-debuggable-flag.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-debugger-checks.yml +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-deeplink-autoverify-missing.yml +33 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-deeplink-unvalidated-parameter.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-device-passcode-present.yml +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-fileprovider-broad-scope.yml +46 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-hardcoded-crypto-keys-usage.yml +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-hardcoded-security-provider.yaml +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-implicit-intent-internal-communication.yml +30 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-implicit-intent-leaking-extras.yml +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-input-field-usage.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-key-generation-with-insufficient-key-length.yml +21 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-keyboard-cache-input-types.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-local-storage-input-validation.yml +48 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-native-debugger-checks.yml +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-checkservertrusted.yml +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-hostname-verification.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-insecure-trust-anchors.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-onreceivedsslerror.yml +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-non-random-use.yml +16 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-object-deserialization.yml +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-overlay-protection.yml +68 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-pendingintent-mutable.yml +39 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-random-apis-insufficient-entropy.yml +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-root-detection.yaml +59 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sdk-version.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sensitive-data-in-notifications-manifest.yml +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sensitive-data-in-notifications.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sensitive-data-in-screenshot.yml +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sql-injection-contentprovider.yml +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-ssl-socket-hostnameverifier.yml +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-strictmode.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-system-alert-window.yml +9 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-allow-local-access.yml +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-bridges.yml +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-safebrowsing.yml +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-url-handlers.yml +41 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/PROVENANCE.json +26 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/network.yaml +37 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/platform.yaml +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/storage.yaml +48 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/LICENSE +165 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/PROVENANCE.json +58 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/auth.yaml +59 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/crypto.yaml +66 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/jailbreak.yaml +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/keyboard.yaml +34 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/logging.yaml +23 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/network.yaml +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/resilience.yaml +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/secrets.yaml +33 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/storage.yaml +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/webview.yaml +32 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/README.md +198 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/__init__.py +3 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/bugx_logging.py +1464 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/daemon_runner.py +623 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/fixture_solidify.py +444 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/global_telemetry.py +549 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/incident_eval.py +148 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/interaction.py +605 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/interaction_store.py +435 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/interactive_menu.py +95 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/log_analytics.py +922 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/mining_quality_framework.py +1387 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/model_runner.py +732 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/platform_adapter.py +579 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/prep_validate.py +478 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_graph.py +827 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_init.py +481 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_profile.py +224 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_settings.py +964 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/provider_window.py +97 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/resume_ticket.py +115 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/scenario_eval.py +856 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/seed_drill.py +549 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/self_audit.py +550 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/session_profile.py +205 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/setup_ui_env.py +229 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/startup_environment.py +859 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/sync_store.py +1421 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/tool_install_targets.py +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/README.md +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/agent-graph.schema.json +368 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/attack-graph.schema.json +88 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/evidence-bundle.schema.json +33 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/skill-pack.schema.json +230 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/worker-checkpoint.schema.json +119 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/secure_atomic.py +289 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/README.md +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/c.txt +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/cpp.txt +32 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/css.txt +70 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/go.txt +46 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/java.txt +30 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/javascript.txt +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/kotlin.txt +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/python.txt +71 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/rust.txt +53 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/swift.txt +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/typescript.txt +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/README.md +53 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/__init__.py +189 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/bugx_docs_mcp_server.py +418 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/bugx_mcp_server.py +1161 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/mcp_runtime.py +968 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/mcp_session_proof.py +605 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/mobile_ui_inspector.py +405 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/skill_pack.py +1214 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/skill_synthesizer.py +1153 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/tools_kb.py +313 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/INTERFACE.md +121 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/README.md +209 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/__init__.py +175 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/audit_supervisor.py +1015 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/budget_governor.py +1254 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/checkpoint_handler.py +368 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/checkpoint_pipeline.py +1564 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/checkpoint_sync.py +653 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/claim_events.py +74 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/claim_sync.py +590 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/cli.py +812 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/context_sync.py +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/coverage_sync.py +115 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finding_commit.py +470 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finding_sync.py +688 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finding_workflow.py +676 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finish_policy.py +224 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finish_sync.py +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/graph_sync.py +669 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/lease_manager.py +788 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/lifecycle_blocks.py +129 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/next_round_sync.py +126 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/observability.py +140 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/recovery_sync.py +165 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/rejection_remedies.py +355 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/round_governor.py +306 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/serial_authorization.py +544 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/start_sync.py +87 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/state_store.py +249 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/supervisor_host.py +511 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/supervisor_models.py +1143 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/systemic_failure.py +104 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/task_scheduler.py +1640 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_checkpoint.py +230 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_execution.py +265 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_handoff.py +192 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_lifecycle.py +396 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_runtime.py +1005 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_sync.py +89 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/README.md +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/__init__.py +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/exceptions.py +52 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/graph_models.py +357 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/path_containment.py +151 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/target_fingerprint.py +310 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/worker_claim.py +411 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/INTERFACE.md +50 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/README.md +57 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/SPEC.md +26 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/__init__.py +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/__init__.py +27 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/base.py +87 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/bugx.py +102 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/claude.py +222 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/cline.py +407 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/codex.py +260 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/dsh.py +177 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/opencode.py +218 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/pi.py +272 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/registry.py +100 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/zcode.py +312 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/api_routes_post.py +668 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/dispatcher.py +1376 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/docs_session_service.py +473 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/handler.py +674 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/ide_cloud_service.py +526 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/mcp_inspector.py +1747 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/00-base.css +1060 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/01-monitoring.css +802 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/02-header-actions.css +321 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/03-trigger-popover.css +697 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/04-composer.css +628 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/05-skills-center.css +878 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/06-mcp-center.css +623 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/07-skill-detail.css +265 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/08-files-management.css +167 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/09-files-center.css +386 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/10-icons.css +105 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/11-project-options.css +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/12-profile-tab.css +383 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/index-CXAsl8mr.js +333 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/index-DHQUtWtx.css +1 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-400-normal-B8Z6Jvzv.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-400-normal-C44pakCn.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-500-normal-Bb4u56_6.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-500-normal-BdVUvljg.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-400-normal-CWV284fw.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-400-normal-DLkyKLvH.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-500-normal-8-8HP2PF.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-500-normal-DaDZE_Na.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-400-normal-BccYJ-vZ.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-400-normal-Cw5-AHNN.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-500-normal-By8GFJzz.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-500-normal-z-Q6FFuG.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-400-normal-DJ5YJwmz.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-400-normal-Dn3IlU-Z.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-500-normal-CUHe9xxf.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-500-normal-DVVamBqs.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-400-normal-CEpydyUl.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-400-normal-Cp7z-ARB.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-500-normal-BYjRCDVy.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-500-normal-D-qasQTj.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-400-normal-BbG3LG1A.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-400-normal-DR1UuFon.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-500-normal-8N8MYVKB.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-500-normal-Bi3OSTTW.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/design-tokens.css +113 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/favicon.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/icon-192.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/index.html +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/manifest.webmanifest +19 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/project-settings.js +9602 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/sw.js +8 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/workspace_service.py +218 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/agents/bugx.md +27 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/dsh-patch.yml +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/mcp/cordis.patch.yml +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/mcp/index.js +219 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/mcp/package.json +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/skills/bugx/SKILL.md +70 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/skills/bugx-dsh/SKILL.md +229 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/client.js +87 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/cordis.patch.yml +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/index.js +7 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/package.json +27 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/mcp-lock.json +3075 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/opencode.json +129 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/pi/extensions/bugx/README.md +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/pi/extensions/bugx/index.ts +299 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/pi/extensions/bugx/manifest.json +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/pi/skills/bugx/SKILL.md +69 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/plugins/bugx/skills/bugx-claude/SKILL.md +326 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/plugins/bugx/skills/bugx-opencode/SKILL.md +129 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/plugins/bugx/skills/bugx-zcode/SKILL.md +459 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/workbuddy/connector-meta.json +19 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/workbuddy/icon.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/workbuddy/skills/bugx/SKILL.md +70 -0
- bugx_cli-0.1.1.dist-info/METADATA +335 -0
- bugx_cli-0.1.1.dist-info/RECORD +762 -0
- bugx_cli-0.1.1.dist-info/WHEEL +5 -0
- bugx_cli-0.1.1.dist-info/entry_points.txt +2 -0
- bugx_cli-0.1.1.dist-info/licenses/LICENSE +55 -0
- bugx_cli-0.1.1.dist-info/top_level.txt +1 -0
bugx_cli/cli.py
ADDED
|
@@ -0,0 +1,1685 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""BugX 统一命令行入口(模块化调度器)。"""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import difflib
|
|
8
|
+
import json
|
|
9
|
+
import os
|
|
10
|
+
import re
|
|
11
|
+
import sys
|
|
12
|
+
import typing
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
# 兼容低版本启动环境:若当前解释器 < 3.11,优先尝试全系统多源自举重拉
|
|
16
|
+
if sys.version_info < (3, 11):
|
|
17
|
+
try:
|
|
18
|
+
_core = Path(__file__).resolve().parent.parent.parent / "core"
|
|
19
|
+
for _entry in (_core.parent, _core):
|
|
20
|
+
if _core.is_dir() and str(_entry) not in sys.path:
|
|
21
|
+
sys.path.insert(0, str(_entry))
|
|
22
|
+
from core.infra import python_runtime
|
|
23
|
+
python_runtime.transparent_reexec_if_needed(min_version=(3, 11))
|
|
24
|
+
except Exception:
|
|
25
|
+
pass
|
|
26
|
+
|
|
27
|
+
from . import __version__
|
|
28
|
+
from .infra.engine_installer import MissingAgentAssetError
|
|
29
|
+
|
|
30
|
+
# 导出基础公共工具与命令模块(保持 100% 向后兼容性)
|
|
31
|
+
from . import common
|
|
32
|
+
from .hosts.registry import (
|
|
33
|
+
autonomous_host_names,
|
|
34
|
+
engine_host_concurrency_bounds,
|
|
35
|
+
engine_host_label,
|
|
36
|
+
)
|
|
37
|
+
from .commands import (
|
|
38
|
+
plugin, lifecycle, agent, doctor, knowledge, cloud, system, stats, project,
|
|
39
|
+
patch, skill, daemon, autonomous, goal, advisory, report, audit, interaction,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class _CloudSyncExplicitAction(argparse.Action):
|
|
44
|
+
"""Record that init's cloud-sync decision came from the command line."""
|
|
45
|
+
|
|
46
|
+
def __call__(self, parser, namespace, values, option_string=None):
|
|
47
|
+
setattr(namespace, self.dest, values)
|
|
48
|
+
setattr(namespace, "cloud_sync_explicit", True)
|
|
49
|
+
|
|
50
|
+
# 将各领域子模块的符号(含公共工具与测试挂载点)全量导出到顶层 cli 命名空间
|
|
51
|
+
for _mod in (
|
|
52
|
+
common, plugin, lifecycle, agent, doctor, knowledge, cloud, system, stats,
|
|
53
|
+
project, patch, skill, daemon, autonomous, goal, advisory, report,
|
|
54
|
+
audit, interaction,
|
|
55
|
+
):
|
|
56
|
+
for _k, _v in vars(_mod).items():
|
|
57
|
+
if not _k.startswith("__"):
|
|
58
|
+
globals()[_k] = _v
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
_COMMAND_DESCRIPTIONS: dict[str, str] = {
|
|
62
|
+
"init": "初始化项目 BugX 核心环境与运行态",
|
|
63
|
+
"doctor": "环境健康度诊断、依赖检测与一键自愈",
|
|
64
|
+
"hosts": "发现系统中已安装的可接入 AI 宿主 Agent",
|
|
65
|
+
"install": "安装 BugX MCP / Skill 至已发现的 AI 宿主",
|
|
66
|
+
"uninstall": "从指定 AI 宿主卸载 BugX 集成",
|
|
67
|
+
"audit": "项目级漏洞渗透挖掘与代码安全审计",
|
|
68
|
+
"interaction": "查看/回答 BugX 抛出的结构化交互问题(非交互宿主答案回灌)",
|
|
69
|
+
"autonomous": "启动全自动无人值守 BugX 漏洞挖掘",
|
|
70
|
+
"analyze": "项目画像深度分析与代码覆盖度全景扫描",
|
|
71
|
+
"project": "项目元数据管理、画像展示与云端同步",
|
|
72
|
+
"patch": "补丁合成、验证、对抗与自动应用",
|
|
73
|
+
"skill": "BugX 动态扩展 Skill 市场管理与挂载",
|
|
74
|
+
"cloud": "BugX 云端多设备协同、同步与设备认证",
|
|
75
|
+
"auth": "云端登录、凭据管理与设备配对",
|
|
76
|
+
"stats": "代码漏洞挖掘统计指标与 ROI 分析",
|
|
77
|
+
"report": "本地 Web 控制台与审计报告预览",
|
|
78
|
+
"engine": "全局引擎核心管理与状态查询",
|
|
79
|
+
"daemon": "BugX 后台常驻守护进程管理",
|
|
80
|
+
"reset": "重置项目运行态或全局错题集缓存",
|
|
81
|
+
"help": "查看 BugX 命令使用说明",
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
_INTENT_SYNONYMS: dict[str, str] = {
|
|
85
|
+
"体检": "doctor",
|
|
86
|
+
"健康": "doctor",
|
|
87
|
+
"修复": "doctor",
|
|
88
|
+
"自愈": "doctor",
|
|
89
|
+
"画像": "project",
|
|
90
|
+
"项目": "project",
|
|
91
|
+
"分析": "analyze",
|
|
92
|
+
"审计": "audit",
|
|
93
|
+
"漏洞": "audit",
|
|
94
|
+
"扫描": "audit",
|
|
95
|
+
"挖掘": "autonomous",
|
|
96
|
+
"自主": "autonomous",
|
|
97
|
+
"无人值守": "autonomous",
|
|
98
|
+
"补丁": "patch",
|
|
99
|
+
"合成": "patch",
|
|
100
|
+
"登录": "auth",
|
|
101
|
+
"认证": "auth",
|
|
102
|
+
"同步": "cloud",
|
|
103
|
+
"云端": "cloud",
|
|
104
|
+
"技能": "skill",
|
|
105
|
+
"插件": "plugin",
|
|
106
|
+
"宿主": "hosts",
|
|
107
|
+
"安装": "install",
|
|
108
|
+
"卸载": "uninstall",
|
|
109
|
+
"重置": "reset",
|
|
110
|
+
"清理": "reset",
|
|
111
|
+
"状态": "stats",
|
|
112
|
+
"统计": "stats",
|
|
113
|
+
"守护": "daemon",
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class _BugXArgumentParser(argparse.ArgumentParser):
|
|
118
|
+
"""带 AI 意图理解与智能模糊纠错的增强参数解析器。"""
|
|
119
|
+
|
|
120
|
+
def error(self, message: str) -> typing.NoReturn:
|
|
121
|
+
match = re.search(r"argument command: invalid choice: '([^']+)'", message)
|
|
122
|
+
if match:
|
|
123
|
+
bad_cmd = match.group(1).strip()
|
|
124
|
+
from .infra.ai_advisor import CommandIntentArbitrator
|
|
125
|
+
# 命令面真值来自解析器自身的 choose-from 清单——建议永不指向不存在的命令。
|
|
126
|
+
choices_match = re.search(r"choose from (.+?)\)", message)
|
|
127
|
+
known = re.findall(r"'([^']+)'", choices_match.group(1)) if choices_match else None
|
|
128
|
+
arbitrator = CommandIntentArbitrator(known_commands=known)
|
|
129
|
+
res = arbitrator.infer_intent(bad_cmd)
|
|
130
|
+
|
|
131
|
+
err_output = [
|
|
132
|
+
f"[bugx] ✗ 未知命令 '{bad_cmd}'",
|
|
133
|
+
]
|
|
134
|
+
if res.suggestions:
|
|
135
|
+
err_output.append(" 🤖 AI 意图理解:您是否想要执行以下命令?")
|
|
136
|
+
for cmd_name, cmd_desc in res.suggestions:
|
|
137
|
+
desc_str = f" - {cmd_desc}" if cmd_desc else ""
|
|
138
|
+
err_output.append(f" 👉 bugx {cmd_name}{desc_str}")
|
|
139
|
+
if res.reasoning:
|
|
140
|
+
err_output.append(f" 💡 意图推断依据: {res.reasoning}")
|
|
141
|
+
else:
|
|
142
|
+
err_output.append(" 查看所有可用命令: bugx --help")
|
|
143
|
+
print("\n".join(err_output), file=sys.stderr)
|
|
144
|
+
sys.exit(2)
|
|
145
|
+
|
|
146
|
+
match_arg = re.search(r"unrecognized arguments:\s*(.+)", message)
|
|
147
|
+
if match_arg:
|
|
148
|
+
bad_args = match_arg.group(1).strip()
|
|
149
|
+
err_output = [f"[bugx] ✗ 参数错误: 未知参数 {bad_args}"]
|
|
150
|
+
if "--mdoe" in bad_args:
|
|
151
|
+
err_output.append(" 💡 AI 纠错建议: 您是否想要输入 '--mode'?")
|
|
152
|
+
elif "--cloude" in bad_args:
|
|
153
|
+
err_output.append(" 💡 AI 纠错建议: 您是否想要输入 '--cloud'?")
|
|
154
|
+
print("\n".join(err_output), file=sys.stderr)
|
|
155
|
+
sys.exit(2)
|
|
156
|
+
|
|
157
|
+
super().error(message)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def _generate_ai_exception_advice(exc: Exception, command: str | None = None) -> str | None:
|
|
161
|
+
"""根据异常类型和上下文,提供 AI 根因诊断与解决建议。"""
|
|
162
|
+
text = str(exc)
|
|
163
|
+
normalized = text.casefold()
|
|
164
|
+
|
|
165
|
+
if "fatal_blocked" in normalized or "project_layout=" in normalized:
|
|
166
|
+
return (
|
|
167
|
+
"BugX 启动门禁已阻断;保留项目现场并停止。先阅读 "
|
|
168
|
+
"`bugx engine --root <ROOT> status --json` 的阻断详情,禁止用 init、reset 或 --force 绕过。"
|
|
169
|
+
)
|
|
170
|
+
if (
|
|
171
|
+
"尚未初始化" in text
|
|
172
|
+
or "not initialized" in text.lower()
|
|
173
|
+
or "manifest.json" in text
|
|
174
|
+
or "缺少项目身份" in text
|
|
175
|
+
or ".bugx-project.json" in text
|
|
176
|
+
):
|
|
177
|
+
return (
|
|
178
|
+
"先运行只读命令 `bugx engine --root <ROOT> status --json`;仅当状态明确为 "
|
|
179
|
+
"`UNINITIALIZED` 时再运行 `bugx engine --root <ROOT> pre`。其他状态保留项目数据并停止。"
|
|
180
|
+
)
|
|
181
|
+
if "已存在" in text or "already exists" in text.lower() or "拒绝覆盖" in text:
|
|
182
|
+
return "目标资产已存在;如需强制覆盖更新,请追加 --force 参数"
|
|
183
|
+
if "未登录" in text or "unauthorized" in text.lower() or "凭据" in text or "token" in text.lower():
|
|
184
|
+
return "当前操作需要云端鉴权,请运行: bugx auth login 登录,或在交互终端执行 bugx project sync"
|
|
185
|
+
if "Connection refused" in text or "网络连接失败" in text or "timed out" in text.lower():
|
|
186
|
+
return "网络通信异常或云端端点超时,请检查系统网络代理,或检查 BUGX_CLOUD_API_BASE 配置"
|
|
187
|
+
if "Permission denied" in text or "权限不足" in text or isinstance(exc, PermissionError):
|
|
188
|
+
return "文件系统读写权限受限,请检查当前用户对相关文件/目录的操作权限"
|
|
189
|
+
if "未找到" in text or "not found" in text.lower() or "missing" in text.lower():
|
|
190
|
+
return "缺少关键依赖或受管配置;先运行只读命令 `bugx doctor --root <ROOT> --json` 查看具体失败项"
|
|
191
|
+
if isinstance(exc, json.JSONDecodeError):
|
|
192
|
+
return (
|
|
193
|
+
"项目 JSON 状态损坏时不会由通用自愈器改写;保留原文件,运行 "
|
|
194
|
+
"`bugx engine --root <ROOT> status --json` 和 `bugx doctor --root <ROOT> --json` 只读诊断,"
|
|
195
|
+
"再从可信备份恢复。"
|
|
196
|
+
)
|
|
197
|
+
return None
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
201
|
+
parser = _BugXArgumentParser(prog="bugx", description=__doc__)
|
|
202
|
+
parser.add_argument("--version", action="version", version=f"%(prog)s {common.get_full_version()}")
|
|
203
|
+
parser.add_argument(
|
|
204
|
+
"--log-level", choices=("DEBUG", "INFO", "WARNING", "ERROR"),
|
|
205
|
+
default=None, help="诊断日志等级(默认 INFO,可由 BUGX_LOG_LEVEL 覆盖)",
|
|
206
|
+
)
|
|
207
|
+
parser.add_argument(
|
|
208
|
+
"--accept-data-sharing", action="store_true",
|
|
209
|
+
help="明确同意脱敏后的单向攻防数据反哺(CI/headless 默认关闭)",
|
|
210
|
+
)
|
|
211
|
+
parser.add_argument(
|
|
212
|
+
"--privacy", choices=("standard", "strict"), default="standard",
|
|
213
|
+
help="strict 仅允许匿名度量出网",
|
|
214
|
+
)
|
|
215
|
+
parser.add_argument(
|
|
216
|
+
"--no-backup", "--skip-backup", action="store_true", dest="no_backup",
|
|
217
|
+
help="跳过执行前自动创建的外部备份归档",
|
|
218
|
+
)
|
|
219
|
+
subparsers = parser.add_subparsers(dest="command", parser_class=_BugXArgumentParser)
|
|
220
|
+
|
|
221
|
+
help_parser = subparsers.add_parser(
|
|
222
|
+
"help", help="显示 BugX 或指定命令的使用说明",
|
|
223
|
+
)
|
|
224
|
+
help_parser.add_argument(
|
|
225
|
+
"help_command", nargs="*", metavar="COMMAND",
|
|
226
|
+
help="可选的命令路径,例如:bugx help cloud sync",
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
completion = subparsers.add_parser(
|
|
230
|
+
"completion", help="输出 Bash、Zsh 或 Fish 的 Tab 补全脚本",
|
|
231
|
+
)
|
|
232
|
+
completion.add_argument("shell", choices=("bash", "zsh", "fish"))
|
|
233
|
+
completion.set_defaults(handler=command_completion)
|
|
234
|
+
|
|
235
|
+
init = subparsers.add_parser("init", help="把宿主无关的 BugX 核心初始化到项目")
|
|
236
|
+
init.add_argument("--root", type=Path, default=Path.cwd())
|
|
237
|
+
init.add_argument("--force", action="store_true", help="更新已有静态文件")
|
|
238
|
+
init.add_argument(
|
|
239
|
+
"--commit-policy", choices=("life", "round", "manual", "none"),
|
|
240
|
+
help="项目默认提交策略:每个 Life、每个 Round、手动提交(manual)或不提交",
|
|
241
|
+
)
|
|
242
|
+
init.add_argument(
|
|
243
|
+
"--cloud-sync", choices=("local", "sync"), default=argparse.SUPPRESS,
|
|
244
|
+
action=_CloudSyncExplicitAction,
|
|
245
|
+
help="项目云端多设备同步策略:local=保持纯本地运行,sync=开启云端同步(非交互模式必须显式指定)",
|
|
246
|
+
)
|
|
247
|
+
init.set_defaults(cloud_sync_explicit=False)
|
|
248
|
+
init.add_argument("--accept-data-sharing", action="store_true", default=argparse.SUPPRESS)
|
|
249
|
+
init.add_argument("--privacy", choices=("standard", "strict"), default=argparse.SUPPRESS)
|
|
250
|
+
init.set_defaults(handler=command_init)
|
|
251
|
+
|
|
252
|
+
dsh = subparsers.add_parser(
|
|
253
|
+
"dsh", help="兼容启动器:为首个 Web Session 绑定项目并启动 DeepSeek Harness",
|
|
254
|
+
)
|
|
255
|
+
dsh.add_argument("--root", type=Path, default=None, help="项目根目录;默认从当前目录向上自动发现")
|
|
256
|
+
dsh.add_argument("--profile", default="web", help="DSH profile(默认 web)")
|
|
257
|
+
dsh.add_argument("dsh_args", nargs=argparse.REMAINDER, help="传给 DSH profile 的参数")
|
|
258
|
+
dsh.set_defaults(handler=command_dsh)
|
|
259
|
+
|
|
260
|
+
hosts = subparsers.add_parser("hosts", help="只读发现可接入的 AI 宿主")
|
|
261
|
+
hosts.add_argument("--root", type=Path, default=Path.cwd())
|
|
262
|
+
hosts.add_argument("--json", action="store_true")
|
|
263
|
+
hosts.set_defaults(agent_command="discover", handler=command_agent)
|
|
264
|
+
|
|
265
|
+
install = subparsers.add_parser(
|
|
266
|
+
"install", help="发现并安装到已安装的 AI Agent",
|
|
267
|
+
)
|
|
268
|
+
install.set_defaults(agent_command="install", handler=command_agent)
|
|
269
|
+
install.add_argument("--root", type=Path, default=Path.cwd())
|
|
270
|
+
install.add_argument("--agent", action="append", default=[], dest="agent")
|
|
271
|
+
install.add_argument("--force", action="store_true")
|
|
272
|
+
install.add_argument("--allow-missing", action="store_true")
|
|
273
|
+
install.add_argument("--non-interactive", action="store_true")
|
|
274
|
+
install.add_argument("--locale", type=str, default=None, help="显式指定安装语言(如 zh-CN, en-US)")
|
|
275
|
+
install.add_argument("--json", action="store_true")
|
|
276
|
+
|
|
277
|
+
reset = subparsers.add_parser(
|
|
278
|
+
"reset", help="归档后重建项目运行态或全局错题集(不删除全局引擎)",
|
|
279
|
+
)
|
|
280
|
+
reset.add_argument("--scope", choices=("project", "global"), default="project",
|
|
281
|
+
help="重置范围:project=当前项目运行态,global=全局错题集")
|
|
282
|
+
reset.add_argument("--root", type=Path, default=Path.cwd())
|
|
283
|
+
reset.add_argument(
|
|
284
|
+
"--reset-knowledge", action="store_true",
|
|
285
|
+
help="项目范围同时重置项目错题集/经验集;仅需一次确认",
|
|
286
|
+
)
|
|
287
|
+
reset.add_argument(
|
|
288
|
+
"--reset-identity", action="store_true",
|
|
289
|
+
help="全局范围同时重置设备 ID 和安装身份密钥",
|
|
290
|
+
)
|
|
291
|
+
reset.add_argument(
|
|
292
|
+
"--reset-credentials", action="store_true",
|
|
293
|
+
help="全局范围同时删除云端凭证(会先备份)",
|
|
294
|
+
)
|
|
295
|
+
reset.add_argument(
|
|
296
|
+
"--reset-mcp-runtime", action="store_true",
|
|
297
|
+
help="全局范围同时清理 MCP lock-hash 运行时缓存",
|
|
298
|
+
)
|
|
299
|
+
reset.add_argument(
|
|
300
|
+
"--reset-backups", action="store_true",
|
|
301
|
+
help="全局范围同时清理历史备份(当前重置备份仍保留)",
|
|
302
|
+
)
|
|
303
|
+
reset.add_argument("--dry-run", action="store_true", help="只显示范围,不修改文件")
|
|
304
|
+
reset.add_argument("--yes", action="store_true", help="确认本次重置,避免交互提示")
|
|
305
|
+
reset.add_argument("--force", action="store_true", help="强制重置(忽略活跃状态检查;执行前依然创建外部备份)")
|
|
306
|
+
reset.add_argument(
|
|
307
|
+
"--no-backup", "--skip-backup", action="store_true", dest="no_backup",
|
|
308
|
+
help="跳过执行前自动创建的外部备份归档",
|
|
309
|
+
)
|
|
310
|
+
reset.add_argument("--json", action="store_true")
|
|
311
|
+
reset.set_defaults(handler=command_reset)
|
|
312
|
+
|
|
313
|
+
uninstall = subparsers.add_parser(
|
|
314
|
+
"uninstall", help="安全卸载 BugX 宿主入口;默认保留报告、证据、配置和错题集",
|
|
315
|
+
)
|
|
316
|
+
uninstall.add_argument("--root", type=Path, default=Path.cwd())
|
|
317
|
+
uninstall.add_argument("--agent", action="append", default=[], dest="agent")
|
|
318
|
+
uninstall.add_argument(
|
|
319
|
+
"--self", action="store_true",
|
|
320
|
+
help="移除全机 BugX 自有工件:~/.bugx(引擎/知识库/云数据)、OpenCode 全局链接、"
|
|
321
|
+
"ZCode plugins.dirs 登记、Pi/dsh 全局注册与 codex 插件登记;不卸载 pip 包",
|
|
322
|
+
)
|
|
323
|
+
uninstall.add_argument(
|
|
324
|
+
"--dry-run", action="store_true",
|
|
325
|
+
help="只预览将清理的目标,不修改任何文件",
|
|
326
|
+
)
|
|
327
|
+
uninstall.add_argument("--all", action="store_true", help="卸载 hosts.json 中全部已安装宿主")
|
|
328
|
+
uninstall.add_argument(
|
|
329
|
+
"--purge-data", action="store_true",
|
|
330
|
+
help="与 --all --yes 同用;外部备份后清理项目 .bugx 和 BugX 共享静态资源",
|
|
331
|
+
)
|
|
332
|
+
uninstall.add_argument(
|
|
333
|
+
"--purge-global-data", action="store_true",
|
|
334
|
+
help="额外清理全局 ~/.bugx/knowledge;会影响其他项目,必须显式确认",
|
|
335
|
+
)
|
|
336
|
+
uninstall.add_argument("--force", action="store_true", help="强制卸载已修改或历史版本的受管宿主入口(卸载前自动备份)")
|
|
337
|
+
uninstall.add_argument("--yes", action="store_true", help="确认不可逆数据清理")
|
|
338
|
+
uninstall.add_argument(
|
|
339
|
+
"--no-backup", "--skip-backup", action="store_true", dest="no_backup",
|
|
340
|
+
help="跳过执行前自动创建的外部备份归档",
|
|
341
|
+
)
|
|
342
|
+
uninstall.add_argument("--json", action="store_true")
|
|
343
|
+
uninstall.set_defaults(handler=command_uninstall)
|
|
344
|
+
|
|
345
|
+
doctor = subparsers.add_parser("doctor", help="诊断安装与项目状态")
|
|
346
|
+
doctor.add_argument("--root", type=Path, default=Path.cwd())
|
|
347
|
+
doctor.add_argument(
|
|
348
|
+
"target", nargs="?", choices=("all", "mcp-runtime"), default="all",
|
|
349
|
+
help="诊断目标:默认整体状态;mcp-runtime 只输出离线 runtime 诊断",
|
|
350
|
+
)
|
|
351
|
+
doctor.add_argument("--json", action="store_true")
|
|
352
|
+
doctor.add_argument(
|
|
353
|
+
"--installation-only", action="store_true",
|
|
354
|
+
help="只验证安装完整性;仍报告但不要求本机已有 OpenCode 模型",
|
|
355
|
+
)
|
|
356
|
+
doctor.add_argument(
|
|
357
|
+
"--repair-assets", "--repair-workbuddy-assets", "--repair", "--fix",
|
|
358
|
+
action="store_true", dest="repair",
|
|
359
|
+
help="--repair-assets:自动修复可自愈项(重建 current.json、对齐版本清单、补齐缺失的受管宿主入口与全局软链等)",
|
|
360
|
+
)
|
|
361
|
+
doctor.add_argument(
|
|
362
|
+
"--agent", action="append", default=[], dest="agent",
|
|
363
|
+
help="定向诊断指定 AI 宿主(可多次指定或逗号分隔,如 --agent claude;默认诊断全部宿主)",
|
|
364
|
+
)
|
|
365
|
+
doctor.add_argument(
|
|
366
|
+
"--strict", action="store_true",
|
|
367
|
+
help="退出码计入可选增强与运行时就绪(默认只以必需安装项判定)",
|
|
368
|
+
)
|
|
369
|
+
doctor.add_argument(
|
|
370
|
+
"--ai", action="store_true",
|
|
371
|
+
help="开启 AI 智能排障与自愈分析(检测到异常时深度剖析根因并输出精准修复处方)",
|
|
372
|
+
)
|
|
373
|
+
doctor.set_defaults(handler=command_doctor)
|
|
374
|
+
|
|
375
|
+
mcp = subparsers.add_parser(
|
|
376
|
+
"mcp", help="启动本地 MCP Supervisor(不执行 worker 命令)",
|
|
377
|
+
)
|
|
378
|
+
mcp_subparsers = mcp.add_subparsers(dest="mcp_command", required=True)
|
|
379
|
+
mcp_serve = mcp_subparsers.add_parser(
|
|
380
|
+
"serve", help="以 stdio 方式启动本地 BugX Supervisor MCP",
|
|
381
|
+
)
|
|
382
|
+
mcp_serve.add_argument(
|
|
383
|
+
"--root", type=Path, default=None,
|
|
384
|
+
help="项目根目录;缺省时依次读 BUGX_PROJECT_ROOT / 宿主工作区环境变量,最后才用 cwd",
|
|
385
|
+
)
|
|
386
|
+
mcp_serve.add_argument(
|
|
387
|
+
"--role", choices=("host", "worker"), default="host",
|
|
388
|
+
help="MCP 通道角色:host 仅主控,worker 仅任务执行",
|
|
389
|
+
)
|
|
390
|
+
mcp_serve.add_argument(
|
|
391
|
+
"--takeover", action="store_true",
|
|
392
|
+
help=(
|
|
393
|
+
"DOC-230 3.1 层 3:仅当 host 持有者闲置超阈值且未自退时接管其租约"
|
|
394
|
+
"(默认关闭)"
|
|
395
|
+
),
|
|
396
|
+
)
|
|
397
|
+
mcp_serve.set_defaults(handler=command_mcp)
|
|
398
|
+
mcp_prune = mcp_subparsers.add_parser(
|
|
399
|
+
"prune", help="清理被遗弃的同项目 MCP 会话进程(默认 dry-run)",
|
|
400
|
+
)
|
|
401
|
+
mcp_prune.add_argument(
|
|
402
|
+
"--root", type=Path, default=None, help="项目根目录(缺省按宿主环境解析)",
|
|
403
|
+
)
|
|
404
|
+
mcp_prune.add_argument(
|
|
405
|
+
"--older-than", type=float, default=1800.0, dest="older_than",
|
|
406
|
+
help="仅清理存活超过该秒数且**无活动记录**的进程(默认 1800)",
|
|
407
|
+
)
|
|
408
|
+
mcp_prune.add_argument(
|
|
409
|
+
"--yes", action="store_true", help="确认执行(缺省只打印将清理的进程)",
|
|
410
|
+
)
|
|
411
|
+
mcp_prune.set_defaults(handler=command_mcp_prune)
|
|
412
|
+
mcp_schema = mcp_subparsers.add_parser(
|
|
413
|
+
"schema", help="输出 MCP 工具契约(不需要项目目录,不启动 Supervisor)",
|
|
414
|
+
)
|
|
415
|
+
mcp_schema.add_argument(
|
|
416
|
+
"--role", choices=("host", "worker"), default="host",
|
|
417
|
+
help="输出 host 或 worker 通道工具",
|
|
418
|
+
)
|
|
419
|
+
mcp_schema.set_defaults(handler=command_mcp_schema)
|
|
420
|
+
|
|
421
|
+
mcp_spy = mcp_subparsers.add_parser(
|
|
422
|
+
"spy", help="以透明中间件管道代理 MCP 子进程并无损 dump 报文流",
|
|
423
|
+
)
|
|
424
|
+
mcp_spy.add_argument(
|
|
425
|
+
"--root", type=Path, default=None,
|
|
426
|
+
help="项目根目录(用于记录 wire 日志到 .bugx/logs/mcp-wire.log)",
|
|
427
|
+
)
|
|
428
|
+
mcp_spy.add_argument(
|
|
429
|
+
"--log", type=Path, default=None,
|
|
430
|
+
help="指定 dump 文件路径(默认 .bugx/logs/mcp-wire.log)",
|
|
431
|
+
)
|
|
432
|
+
mcp_spy.add_argument("spy_cmd", nargs=argparse.REMAINDER, help="被代理的底层 MCP 命令与参数")
|
|
433
|
+
mcp_spy.set_defaults(handler=command_mcp_spy)
|
|
434
|
+
|
|
435
|
+
mcp_docs = mcp_subparsers.add_parser(
|
|
436
|
+
"docs", help="索引或启动本地项目文档 MCP(无第三方 API Key)",
|
|
437
|
+
)
|
|
438
|
+
mcp_docs_subparsers = mcp_docs.add_subparsers(
|
|
439
|
+
dest="mcp_docs_command", required=True,
|
|
440
|
+
)
|
|
441
|
+
for command_name, help_text in (
|
|
442
|
+
("index", "索引 README/docs/core Markdown 到 SQLite FTS5"),
|
|
443
|
+
("serve", "以 stdio 方式启动只读文档 MCP"),
|
|
444
|
+
):
|
|
445
|
+
docs_command = mcp_docs_subparsers.add_parser(command_name, help=help_text)
|
|
446
|
+
docs_command.add_argument(
|
|
447
|
+
"--root", type=Path, default=None,
|
|
448
|
+
help="项目根目录;缺省时依次读 BUGX_PROJECT_ROOT / 宿主工作区环境变量,最后才用 cwd",
|
|
449
|
+
)
|
|
450
|
+
docs_command.add_argument(
|
|
451
|
+
"--db", type=Path, default=Path(".bugx/knowledge/docs.sqlite3"),
|
|
452
|
+
)
|
|
453
|
+
docs_command.add_argument("--project-id", default=None)
|
|
454
|
+
docs_command.add_argument("--version", default=None)
|
|
455
|
+
if command_name == "serve":
|
|
456
|
+
docs_command.add_argument("--no-auto-index", action="store_true")
|
|
457
|
+
docs_command.set_defaults(handler=command_mcp_docs)
|
|
458
|
+
|
|
459
|
+
capability = subparsers.add_parser(
|
|
460
|
+
"capability",
|
|
461
|
+
help="探查项目形态并装配能力:plan(只读)/ install(装齐所需 MCP 运行时)",
|
|
462
|
+
)
|
|
463
|
+
capability_sub = capability.add_subparsers(
|
|
464
|
+
dest="capability_command", required=True,
|
|
465
|
+
)
|
|
466
|
+
|
|
467
|
+
def _add_capability_common(sub_parser: argparse.ArgumentParser) -> None:
|
|
468
|
+
sub_parser.add_argument("--root", type=Path, default=None,
|
|
469
|
+
help="项目根目录(缺省当前目录)")
|
|
470
|
+
sub_parser.add_argument("--json", action="store_true")
|
|
471
|
+
|
|
472
|
+
cap_plan = capability_sub.add_parser(
|
|
473
|
+
"plan", help="只读输出「画像 → 技能包 → MCP/工具」装配计划",
|
|
474
|
+
)
|
|
475
|
+
_add_capability_common(cap_plan)
|
|
476
|
+
cap_plan.set_defaults(handler=command_capability)
|
|
477
|
+
|
|
478
|
+
cap_install = capability_sub.add_parser(
|
|
479
|
+
"install",
|
|
480
|
+
help="按计划装齐所需 MCP 运行时(缺凭据的能力自动跳过并提示环境变量)",
|
|
481
|
+
)
|
|
482
|
+
_add_capability_common(cap_install)
|
|
483
|
+
cap_install.add_argument("--runtime-root", type=Path, default=None,
|
|
484
|
+
help="覆盖 runtime 根目录(默认 ~/.bugx/mcp-runtime)")
|
|
485
|
+
cap_install.add_argument("--lock", type=Path, default=None,
|
|
486
|
+
help="覆盖 lock 文件(默认使用随 BugX 发布的锁定版本)")
|
|
487
|
+
cap_install.set_defaults(handler=command_capability)
|
|
488
|
+
|
|
489
|
+
mcp_runtime = subparsers.add_parser(
|
|
490
|
+
"mcp-runtime",
|
|
491
|
+
help="lock-hash 专用离线 MCP runtime:install/verify/start/rollback",
|
|
492
|
+
)
|
|
493
|
+
mcp_runtime_sub = mcp_runtime.add_subparsers(
|
|
494
|
+
dest="mcp_runtime_command", required=True,
|
|
495
|
+
)
|
|
496
|
+
|
|
497
|
+
def _add_runtime_common(sub_parser: argparse.ArgumentParser) -> None:
|
|
498
|
+
sub_parser.add_argument("--root", type=Path, default=Path.cwd())
|
|
499
|
+
sub_parser.add_argument(
|
|
500
|
+
"--runtime-root", type=Path, default=None,
|
|
501
|
+
help="覆盖 runtime 根目录(默认 ~/.bugx/mcp-runtime)",
|
|
502
|
+
)
|
|
503
|
+
|
|
504
|
+
rt_install = mcp_runtime_sub.add_parser(
|
|
505
|
+
"install", help="按 mcp-lock.json 安装并原子发布新 lock-hash runtime",
|
|
506
|
+
)
|
|
507
|
+
_add_runtime_common(rt_install)
|
|
508
|
+
rt_install.add_argument("--lock", type=Path, default=None,
|
|
509
|
+
help="覆盖 lock 文件(默认使用随 BugX 发布的锁定版本)")
|
|
510
|
+
rt_install.add_argument("--json", action="store_true")
|
|
511
|
+
rt_install.set_defaults(handler=command_mcp_runtime)
|
|
512
|
+
|
|
513
|
+
rt_verify = mcp_runtime_sub.add_parser(
|
|
514
|
+
"verify", help="深度校验当前 runtime(文件树/入口/manifest/Node)",
|
|
515
|
+
)
|
|
516
|
+
_add_runtime_common(rt_verify)
|
|
517
|
+
rt_verify.add_argument("--json", action="store_true")
|
|
518
|
+
rt_verify.set_defaults(handler=command_mcp_runtime)
|
|
519
|
+
|
|
520
|
+
rt_start = mcp_runtime_sub.add_parser(
|
|
521
|
+
"start", help="校验后直接以 node 启动指定 MCP 服务入口(不联网下载)",
|
|
522
|
+
)
|
|
523
|
+
_add_runtime_common(rt_start)
|
|
524
|
+
rt_start.add_argument("--server", required=True,
|
|
525
|
+
help="MCP 服务名(由 mcp-lock.json servers 定义)")
|
|
526
|
+
rt_start.add_argument(
|
|
527
|
+
"--print-command", action="store_true",
|
|
528
|
+
help="只打印将执行的 argv 与策略(JSON),不真正启动",
|
|
529
|
+
)
|
|
530
|
+
rt_start.set_defaults(handler=command_mcp_runtime)
|
|
531
|
+
|
|
532
|
+
rt_rollback = mcp_runtime_sub.add_parser(
|
|
533
|
+
"rollback", help="把 current 切回上一批准 lock-hash;不重新下载",
|
|
534
|
+
)
|
|
535
|
+
_add_runtime_common(rt_rollback)
|
|
536
|
+
rt_rollback.add_argument("--json", action="store_true")
|
|
537
|
+
rt_rollback.set_defaults(handler=command_mcp_runtime)
|
|
538
|
+
|
|
539
|
+
lesson = subparsers.add_parser("lesson", help="管理项目级结构化错题集")
|
|
540
|
+
lesson.add_argument(
|
|
541
|
+
"lesson_command",
|
|
542
|
+
choices=("init", "bootstrap", "migrate", "validate", "rebuild", "rebuild-fts", "archive-events",
|
|
543
|
+
"incident-archive", "retrieve", "record",
|
|
544
|
+
"review", "feedback", "metrics", "hygiene", "merge", "retire", "revoke",
|
|
545
|
+
"export", "backup", "replay", "incident-add", "incident-lookup",
|
|
546
|
+
"incident-activate", "incident-revoke",
|
|
547
|
+
"tool-feedback", "tool-metrics", "tool-lookup", "tool-matrix",
|
|
548
|
+
"export-book", "promote", "promote-incident", "promote-tool", "inherit", "evidence-add", "incident-list",
|
|
549
|
+
"consume", "tool-exp-export", "tool-exp-import"),
|
|
550
|
+
)
|
|
551
|
+
lesson.add_argument("--root", type=Path, default=Path.cwd())
|
|
552
|
+
lesson.add_argument("--ledger", type=Path)
|
|
553
|
+
lesson.add_argument("--input", type=Path)
|
|
554
|
+
lesson.add_argument("--output", type=Path)
|
|
555
|
+
lesson.add_argument("--query", default="")
|
|
556
|
+
lesson.add_argument("--category")
|
|
557
|
+
lesson.add_argument("--limit", type=int, default=6)
|
|
558
|
+
lesson.add_argument("--offset", type=int, default=0)
|
|
559
|
+
lesson.add_argument("--token-budget", type=int, default=1500)
|
|
560
|
+
lesson.add_argument("--byte-budget", type=int, default=12000)
|
|
561
|
+
lesson.add_argument("--exclude-lesson-id", action="append", default=[])
|
|
562
|
+
lesson.add_argument("--finding-fingerprint")
|
|
563
|
+
lesson.add_argument("--tool", action="append", default=[],
|
|
564
|
+
help="tool-feedback 归因的工具名,可重复")
|
|
565
|
+
lesson.add_argument("--signature", action="append", default=[])
|
|
566
|
+
lesson.add_argument("--pattern-id")
|
|
567
|
+
lesson.add_argument(
|
|
568
|
+
"--finding", type=Path,
|
|
569
|
+
help="hit 反馈对应的已通过确认门禁的 finding JSON",
|
|
570
|
+
)
|
|
571
|
+
lesson.add_argument("--lesson-id")
|
|
572
|
+
lesson.add_argument("--incident-id")
|
|
573
|
+
lesson.add_argument("--evidence-receipt-id")
|
|
574
|
+
lesson.add_argument("--lifecycle-id")
|
|
575
|
+
lesson.add_argument("--round", type=int)
|
|
576
|
+
lesson.add_argument("--outcome")
|
|
577
|
+
lesson.add_argument("--event-id")
|
|
578
|
+
lesson.add_argument("--subject-type")
|
|
579
|
+
lesson.add_argument("--subject-id")
|
|
580
|
+
lesson.add_argument("--event-type")
|
|
581
|
+
lesson.add_argument("--source-pattern-id")
|
|
582
|
+
lesson.add_argument("--target-pattern-id")
|
|
583
|
+
lesson.add_argument("--reason")
|
|
584
|
+
lesson.add_argument("--min-feedback", type=int, default=3)
|
|
585
|
+
lesson.add_argument(
|
|
586
|
+
"--deep", action="store_true",
|
|
587
|
+
help="validate 的深度校验:事件链、关系、receipt、tombstone、FTS 和归档段",
|
|
588
|
+
)
|
|
589
|
+
lesson.add_argument(
|
|
590
|
+
"--from-seed", action="store_true",
|
|
591
|
+
help="rebuild 从全局 JSON 种子重建 SQLite(仅用于显式恢复)",
|
|
592
|
+
)
|
|
593
|
+
lesson.add_argument(
|
|
594
|
+
"--confirm-data-loss", action="store_true",
|
|
595
|
+
help="确认替换损坏或缺失的 SQLite 运行库,并保留 .corrupt.bak",
|
|
596
|
+
)
|
|
597
|
+
lesson.add_argument(
|
|
598
|
+
"--keep-tail", type=int, default=0,
|
|
599
|
+
help="archive-events 保留活动事件尾部数量(默认 0)",
|
|
600
|
+
)
|
|
601
|
+
lesson.add_argument(
|
|
602
|
+
"--older-than-days", type=int, default=90,
|
|
603
|
+
help="incident-archive 只处理超过该天数的记录(默认 90)",
|
|
604
|
+
)
|
|
605
|
+
lesson.add_argument(
|
|
606
|
+
"--max-archive", type=int, default=50,
|
|
607
|
+
help="incident-archive 单次最多处理数量(默认 50)",
|
|
608
|
+
)
|
|
609
|
+
lesson.add_argument("--cases", type=Path)
|
|
610
|
+
lesson.add_argument("--mode", choices=("cases", "gain", "tools"), default="cases",
|
|
611
|
+
help="replay 模式:cases=模式检索;gain=incident 时序 holdout;tools=工具经验")
|
|
612
|
+
lesson.add_argument("--holdout-mod", type=int, default=5)
|
|
613
|
+
lesson.add_argument("--holdout-remainder", type=int, default=0)
|
|
614
|
+
lesson.add_argument("--json", action="store_true")
|
|
615
|
+
lesson.set_defaults(handler=command_lesson)
|
|
616
|
+
|
|
617
|
+
logic_analysis = subparsers.add_parser(
|
|
618
|
+
"logic-analysis", help="校验或绑定意图、逻辑链、Oracle 与证据包",
|
|
619
|
+
)
|
|
620
|
+
logic_analysis.add_argument(
|
|
621
|
+
"logic_command", choices=("validate", "bind", "bind-finding"),
|
|
622
|
+
help="validate=校验证据包;bind=绑定到 CoverageTask;bind-finding=绑定到 Finding",
|
|
623
|
+
)
|
|
624
|
+
logic_analysis.add_argument("--root", type=Path, default=Path.cwd())
|
|
625
|
+
logic_analysis.add_argument("--input", type=Path, required=True,
|
|
626
|
+
help="logic analysis bundle JSON")
|
|
627
|
+
logic_analysis.add_argument("--task", type=Path,
|
|
628
|
+
help="bind 时提供待绑定的 CoverageTask JSON")
|
|
629
|
+
logic_analysis.add_argument("--finding", type=Path,
|
|
630
|
+
help="bind-finding 时提供待绑定的 Finding JSON")
|
|
631
|
+
logic_analysis.add_argument("--output", type=Path,
|
|
632
|
+
help="bind 输出路径(缺省输出到 stdout)")
|
|
633
|
+
logic_analysis.set_defaults(handler=command_logic_analysis)
|
|
634
|
+
|
|
635
|
+
probe = subparsers.add_parser(
|
|
636
|
+
"probe", help="运行 core 探针(efficiency/sast/mobile 等),透传其参数",
|
|
637
|
+
)
|
|
638
|
+
probe.add_argument(
|
|
639
|
+
"probe_kind",
|
|
640
|
+
choices=tuple(PROBE_SCRIPTS),
|
|
641
|
+
help="探针类别(对应 <kind>_probe.py)",
|
|
642
|
+
)
|
|
643
|
+
probe.add_argument("--root", type=Path, default=Path.cwd(),
|
|
644
|
+
help="项目根(默认当前目录)")
|
|
645
|
+
probe.add_argument("probe_args", nargs=argparse.REMAINDER,
|
|
646
|
+
help="透传给探针的参数(如 check --json --strict)")
|
|
647
|
+
|
|
648
|
+
knowledge = subparsers.add_parser(
|
|
649
|
+
"knowledge", help="治理项目候选与用户全局错题集(不自动同步)",
|
|
650
|
+
)
|
|
651
|
+
knowledge.add_argument(
|
|
652
|
+
"knowledge_command", choices=("status", "export", "approve", "import", "rollback"),
|
|
653
|
+
)
|
|
654
|
+
knowledge.add_argument("--root", type=Path, default=Path.cwd())
|
|
655
|
+
knowledge.add_argument("--bundle", type=Path)
|
|
656
|
+
knowledge.add_argument("--output", type=Path)
|
|
657
|
+
knowledge.add_argument("--bundle-id")
|
|
658
|
+
knowledge.add_argument("--contributor", default="local-supervisor")
|
|
659
|
+
knowledge.add_argument(
|
|
660
|
+
"--include-source-snippets", action="store_true",
|
|
661
|
+
help="导出时在便携包中携带 before/after 源码片段(默认不带;开启后经片段级审查)",
|
|
662
|
+
)
|
|
663
|
+
knowledge.add_argument("--reviewer")
|
|
664
|
+
knowledge.add_argument("--reason")
|
|
665
|
+
knowledge.set_defaults(handler=command_knowledge)
|
|
666
|
+
probe.set_defaults(handler=command_probe)
|
|
667
|
+
|
|
668
|
+
skill_cmd = subparsers.add_parser(
|
|
669
|
+
"skill", help="审计技能包管理、图谱状态查询、契约校验与原子回滚",
|
|
670
|
+
)
|
|
671
|
+
skill_cmd.add_argument(
|
|
672
|
+
"skill_action", choices=("list", "status", "validate", "rollback", "import", "pull"),
|
|
673
|
+
)
|
|
674
|
+
skill_cmd.add_argument("--root", type=Path, default=Path.cwd())
|
|
675
|
+
skill_cmd.add_argument("--skill", default="web-audit")
|
|
676
|
+
skill_cmd.add_argument("--bundle", type=Path, help="离线技能包归档")
|
|
677
|
+
skill_cmd.add_argument("--json", action="store_true")
|
|
678
|
+
skill_cmd.set_defaults(handler=command_skill)
|
|
679
|
+
|
|
680
|
+
self_audit = subparsers.add_parser(
|
|
681
|
+
"self-audit", help="对 BugX 本地 CLI/MCP 只读入口做自举动态审计",
|
|
682
|
+
)
|
|
683
|
+
self_audit.add_argument("--root", type=Path, default=Path.cwd(),
|
|
684
|
+
help="项目根(默认当前目录)")
|
|
685
|
+
self_audit.add_argument(
|
|
686
|
+
"self_audit_args", nargs=argparse.REMAINDER,
|
|
687
|
+
help="透传给 self_audit.py(缺省运行 all 模式)",
|
|
688
|
+
)
|
|
689
|
+
self_audit.set_defaults(handler=command_self_audit)
|
|
690
|
+
|
|
691
|
+
engine = subparsers.add_parser(
|
|
692
|
+
"engine", help="从全局引擎运行生命周期命令(项目不再提供 .bugx/core 入口)",
|
|
693
|
+
)
|
|
694
|
+
engine.add_argument(
|
|
695
|
+
"--root", type=Path, default=None,
|
|
696
|
+
help="项目根目录;缺省时依次读 BUGX_PROJECT_ROOT / 宿主工作区环境变量,最后才用 cwd",
|
|
697
|
+
)
|
|
698
|
+
engine.add_argument(
|
|
699
|
+
"engine_args", nargs=argparse.REMAINDER,
|
|
700
|
+
help="透传给全局生命周期引擎;例如 pre、status、workers、post",
|
|
701
|
+
)
|
|
702
|
+
engine.set_defaults(handler=command_engine)
|
|
703
|
+
|
|
704
|
+
cloud = subparsers.add_parser("cloud", help="云端错题/经验集同步(显式命令)")
|
|
705
|
+
cloud_sub = cloud.add_subparsers(dest="cloud_command", required=True)
|
|
706
|
+
|
|
707
|
+
def _cloud_common(p):
|
|
708
|
+
p.add_argument("--root", type=Path, default=Path.cwd())
|
|
709
|
+
p.add_argument("--project-slug", dest="project_slug", help="项目 slug(缺省=仓库目录名)")
|
|
710
|
+
p.add_argument("--accept-data-sharing", action="store_true", default=argparse.SUPPRESS)
|
|
711
|
+
p.add_argument("--privacy", choices=("standard", "strict"), default=argparse.SUPPRESS)
|
|
712
|
+
p.set_defaults(handler=command_cloud)
|
|
713
|
+
return p
|
|
714
|
+
|
|
715
|
+
auth = subparsers.add_parser("auth", help="登录、查看、设置或清除云端登录态")
|
|
716
|
+
|
|
717
|
+
def _auth_common(p):
|
|
718
|
+
p.add_argument("--root", type=Path, default=Path.cwd())
|
|
719
|
+
p.add_argument("--project-slug", dest="project_slug", help="项目 slug(缺省=仓库目录名)")
|
|
720
|
+
p.add_argument("--accept-data-sharing", action="store_true", default=argparse.SUPPRESS)
|
|
721
|
+
p.add_argument("--privacy", choices=("standard", "strict"), default=argparse.SUPPRESS)
|
|
722
|
+
p.set_defaults(handler=command_cloud, cloud_command="auth")
|
|
723
|
+
return p
|
|
724
|
+
|
|
725
|
+
p_auth = _auth_common(auth)
|
|
726
|
+
p_auth.add_argument("auth_action", choices=("login", "status", "set-key", "logout"))
|
|
727
|
+
p_auth.add_argument("--api-key", dest="api_key")
|
|
728
|
+
p_auth.add_argument("--json", action="store_true")
|
|
729
|
+
p_auth.add_argument(
|
|
730
|
+
"--verify", dest="verify_auth", action="store_true",
|
|
731
|
+
help="通过只读云端接口验证登录态(可能触发刷新令牌,不创建或修改业务数据)",
|
|
732
|
+
)
|
|
733
|
+
p_config = _cloud_common(cloud_sub.add_parser(
|
|
734
|
+
"config", help="查看或设置全局云端 API Base URL / 版本检查(不保存凭证)",
|
|
735
|
+
))
|
|
736
|
+
config_group = p_config.add_mutually_exclusive_group()
|
|
737
|
+
config_group.add_argument("--base-url", help="云端 API Base URL,例如 https://bugx.example.com")
|
|
738
|
+
config_group.add_argument("--clear", dest="clear_base_url", action="store_true",
|
|
739
|
+
help="清除持久化 Base URL,恢复默认地址")
|
|
740
|
+
config_group.add_argument(
|
|
741
|
+
"--refresh-route", dest="refresh_route", action="store_true",
|
|
742
|
+
help="强制清除路由测速缓存并重新并发竞速优选",
|
|
743
|
+
)
|
|
744
|
+
config_group.add_argument(
|
|
745
|
+
"--disable-version-check", dest="disable_version_check",
|
|
746
|
+
choices=("true", "false"), default=None,
|
|
747
|
+
help="设置是否禁用启动时版本检查(true=禁用,false=启用)",
|
|
748
|
+
)
|
|
749
|
+
p_config.add_argument("--json", action="store_true")
|
|
750
|
+
p_status = _cloud_common(cloud_sub.add_parser(
|
|
751
|
+
"status", help="只读查看本地同步 cursor、失败、队列和冲突状态",
|
|
752
|
+
))
|
|
753
|
+
p_status.add_argument(
|
|
754
|
+
"--scope", dest="status_scope", choices=("project", "global", "all"), default="all",
|
|
755
|
+
help="查看范围;默认 all",
|
|
756
|
+
)
|
|
757
|
+
p_status.add_argument("--json", action="store_true")
|
|
758
|
+
p_log = _cloud_common(cloud_sub.add_parser(
|
|
759
|
+
"log-report",
|
|
760
|
+
help="上报本项目的诊断日志(内测期排查用;仅在 AI/用户显式要求时调用,默认不上报)",
|
|
761
|
+
description="打包项目诊断日志(bugx.jsonl 尾部)上报到云端 POST"
|
|
762
|
+
" /api/v1/agent/log-reports(登录认证 + 每日限额,限额管理端可配)。",
|
|
763
|
+
))
|
|
764
|
+
p_log.add_argument("--tail-kb", dest="tail_kb", type=int, default=256,
|
|
765
|
+
help="日志尾部大小上限(KB,默认 256)")
|
|
766
|
+
p_log.add_argument("--kind", dest="kind", default="cli-diagnostics",
|
|
767
|
+
help="上报类型标记(默认 cli-diagnostics)")
|
|
768
|
+
p_log.add_argument("--json", action="store_true")
|
|
769
|
+
p_feedback = _cloud_common(cloud_sub.add_parser(
|
|
770
|
+
"feedback",
|
|
771
|
+
help="扫描收尾批量上报错题卡质量反馈(hit-feedback 质量闭环)",
|
|
772
|
+
description="把本地错题卡反馈批量回报云端 POST /api/v1/agent/lessons/hit-feedback"
|
|
773
|
+
"(outcome ∈ hit|miss|false_positive|rejected)。",
|
|
774
|
+
))
|
|
775
|
+
p_feedback.add_argument("--lifecycle", dest="lifecycle",
|
|
776
|
+
help="仅上报指定 lifecycle 的反馈(缺省=全部本地反馈)")
|
|
777
|
+
p_feedback.add_argument("--run-id", dest="run_id", default="",
|
|
778
|
+
help="云端日志上下文 run_id(可选,不落库)")
|
|
779
|
+
p_feedback.add_argument("--project", dest="project_name", default="",
|
|
780
|
+
help="云端日志上下文项目名(可选,不落库)")
|
|
781
|
+
p_feedback.add_argument("--limit", type=int, default=100,
|
|
782
|
+
help="单次上报上限(1..100,默认 100)")
|
|
783
|
+
p_feedback.add_argument("--dry-run", action="store_true",
|
|
784
|
+
help="只打印将上报的条目,不联网")
|
|
785
|
+
p_feedback.add_argument("--json", action="store_true")
|
|
786
|
+
p_sync = _cloud_common(cloud_sub.add_parser(
|
|
787
|
+
"sync", help="立即执行云端同步;未登录时自动打开授权页",
|
|
788
|
+
))
|
|
789
|
+
p_sync.add_argument("--scope", dest="sync_scope", choices=("project", "global", "all"), default=None,
|
|
790
|
+
help="显式授权同步范围;缺省读 cloud-config.json sync_scope_default(默认 all)")
|
|
791
|
+
p_sync.add_argument("--detail-mode", choices=("full", "summary"), default=None,
|
|
792
|
+
help="私有同步详情粒度;缺省读 cloud-config.json sync_detail_mode(默认 full),summary 仅上传摘要/计数/状态")
|
|
793
|
+
p_sync.add_argument("--calibrate", action="store_true",
|
|
794
|
+
help="自动校准基线:重置失效游标、修剪已收敛冲突并自愈恢复基线状态")
|
|
795
|
+
p_export = _cloud_common(cloud_sub.add_parser(
|
|
796
|
+
"export", help="把本地知识导出为可恢复的 V2 JSON bundle(不联网)",
|
|
797
|
+
))
|
|
798
|
+
p_export.add_argument("--scope", dest="bundle_scope", choices=("global", "project"),
|
|
799
|
+
default="project", help="导出范围;默认 project")
|
|
800
|
+
p_export.add_argument("--detail-mode", choices=("full", "summary"), default="full")
|
|
801
|
+
p_export.add_argument("--output", required=True, help="JSON 输出文件路径")
|
|
802
|
+
p_upload = _cloud_common(cloud_sub.add_parser(
|
|
803
|
+
"upload", help="上传本地 V2 JSON bundle 并可恢复本地同步基线",
|
|
804
|
+
))
|
|
805
|
+
p_upload.add_argument("--input", required=True, help="JSON bundle 文件路径")
|
|
806
|
+
p_upload.add_argument("--mode", choices=("merge", "local_authoritative"),
|
|
807
|
+
default="merge")
|
|
808
|
+
p_upload.add_argument("--json", action="store_true")
|
|
809
|
+
p_conflicts = _cloud_common(cloud_sub.add_parser(
|
|
810
|
+
"conflicts", help="查看和治理本地同步冲突队列(list / resolve / prune,不联网)",
|
|
811
|
+
))
|
|
812
|
+
p_conflicts.add_argument(
|
|
813
|
+
"conflict_action", nargs="?", choices=("list", "resolve", "prune"), default="list",
|
|
814
|
+
help="list=列出待治理冲突(默认);resolve=按选边解决一条冲突;prune=自动修剪已收敛冲突",
|
|
815
|
+
)
|
|
816
|
+
p_conflicts.add_argument("conflict_id", nargs="?", help="resolve 的目标 conflict_id")
|
|
817
|
+
p_conflicts.add_argument(
|
|
818
|
+
"--side", dest="conflict_side", choices=("local", "remote"),
|
|
819
|
+
help="resolve 选边:local=保留本地丢弃远端记录;remote=接受远端",
|
|
820
|
+
)
|
|
821
|
+
p_conflicts.add_argument(
|
|
822
|
+
"--scope", dest="conflict_scope", choices=("project", "global", "all"), default="all",
|
|
823
|
+
help="查看/解决范围;默认 all",
|
|
824
|
+
)
|
|
825
|
+
p_conflicts.add_argument(
|
|
826
|
+
"--all", dest="conflict_all", action="store_true",
|
|
827
|
+
help="resolve 批量形态:按选边解决范围内全部 open 冲突(与 conflict_id 互斥)",
|
|
828
|
+
)
|
|
829
|
+
p_conflicts.add_argument(
|
|
830
|
+
"--reason-filter", dest="conflict_reason_filter", default="",
|
|
831
|
+
help="配合 --all:仅解决 reason 匹配的冲突,例如 content_diverged",
|
|
832
|
+
)
|
|
833
|
+
p_conflicts.add_argument("--json", action="store_true")
|
|
834
|
+
p_dead = _cloud_common(cloud_sub.add_parser(
|
|
835
|
+
"dead-letter", help="查看与清理同步死信队列(list / purge,不联网)",
|
|
836
|
+
))
|
|
837
|
+
p_dead.add_argument(
|
|
838
|
+
"dead_letter_action", nargs="?", choices=("list", "purge"), default="list",
|
|
839
|
+
help="list=列出死信(默认);purge=清理死信(需 --confirm,先归档后删除)",
|
|
840
|
+
)
|
|
841
|
+
p_dead.add_argument(
|
|
842
|
+
"--confirm", dest="dead_letter_confirm", action="store_true",
|
|
843
|
+
help="确认执行删除;缺省仅 dry-run 打印将删条数",
|
|
844
|
+
)
|
|
845
|
+
p_dead.add_argument(
|
|
846
|
+
"--scope", dest="dead_letter_scope", choices=("project", "global", "all"), default="all",
|
|
847
|
+
help="列出/清理范围;默认 all",
|
|
848
|
+
)
|
|
849
|
+
p_dead.add_argument(
|
|
850
|
+
"--older-than-days", dest="dead_letter_older_than_days", type=int, default=0,
|
|
851
|
+
help="仅处理 created_at 早于 N 天的死信;0=全部(默认)",
|
|
852
|
+
)
|
|
853
|
+
p_dead.add_argument("--json", action="store_true")
|
|
854
|
+
p_proj = _cloud_common(cloud_sub.add_parser("projects"))
|
|
855
|
+
p_proj.add_argument("cloud_project_action", choices=("list", "add"))
|
|
856
|
+
|
|
857
|
+
_cloud_common(cloud_sub.add_parser("devices"))
|
|
858
|
+
p_onb = _cloud_common(cloud_sub.add_parser(
|
|
859
|
+
"onboard", help="查看或切换项目同步;on 会立即同步 global + project",
|
|
860
|
+
))
|
|
861
|
+
p_onb.add_argument(
|
|
862
|
+
"onboard_action", nargs="?", choices=("status", "on", "off"), default="status",
|
|
863
|
+
help="status=查看;on=开启并立即同步;off=关闭自动同步并进入本地模式",
|
|
864
|
+
)
|
|
865
|
+
|
|
866
|
+
telemetry = subparsers.add_parser("telemetry", help="查看或导出单向飞轮取证数据")
|
|
867
|
+
telemetry_sub = telemetry.add_subparsers(dest="telemetry_command", required=True)
|
|
868
|
+
telemetry_inspect = telemetry_sub.add_parser("inspect", help="检查本地出网取证日志")
|
|
869
|
+
telemetry_inspect.add_argument("--latest", action="store_true")
|
|
870
|
+
telemetry_inspect.add_argument("--json", action="store_true")
|
|
871
|
+
telemetry_inspect.set_defaults(handler=command_telemetry)
|
|
872
|
+
telemetry_export = telemetry_sub.add_parser("export", help="导出加密离线穿梭包")
|
|
873
|
+
telemetry_export.add_argument("--out", type=Path, required=True)
|
|
874
|
+
telemetry_export.add_argument("--passphrase")
|
|
875
|
+
telemetry_export.set_defaults(handler=command_telemetry)
|
|
876
|
+
telemetry_flush = telemetry_sub.add_parser("flush", help="主动推送并清空本地脱敏出网飞轮队列 (upload)")
|
|
877
|
+
telemetry_flush.add_argument("--batch-size", type=int, default=20, help="每批聚合上报条数")
|
|
878
|
+
telemetry_flush.set_defaults(handler=command_telemetry)
|
|
879
|
+
telemetry_upload = telemetry_sub.add_parser("upload", help="主动推送并清空本地脱敏出网飞轮队列 (flush 别名)")
|
|
880
|
+
telemetry_upload.add_argument("--batch-size", type=int, default=20, help="每批聚合上报条数")
|
|
881
|
+
telemetry_upload.set_defaults(handler=command_telemetry)
|
|
882
|
+
|
|
883
|
+
config = subparsers.add_parser("config", help="设置本地 BugX 隐私与遥测配置")
|
|
884
|
+
config_sub = config.add_subparsers(dest="config_command", required=True)
|
|
885
|
+
config_set = config_sub.add_parser("set", help="设置一项配置")
|
|
886
|
+
config_set.add_argument(
|
|
887
|
+
"config_key",
|
|
888
|
+
choices=("telemetry.data_sharing",
|
|
889
|
+
"cloud.sync_detail_mode", "cloud.sensitive_policy",
|
|
890
|
+
"cloud.sync_scope_default"),
|
|
891
|
+
help="telemetry.data_sharing=遥测数据分享;cloud.*=DOC-211 同步内容策略",
|
|
892
|
+
)
|
|
893
|
+
config_set.add_argument(
|
|
894
|
+
"config_value",
|
|
895
|
+
help="telemetry.data_sharing 取 true/false;cloud.sync_detail_mode 取 full/summary;"
|
|
896
|
+
"cloud.sensitive_policy 取 block/redact/allow;cloud.sync_scope_default 取 all/project/global",
|
|
897
|
+
)
|
|
898
|
+
config_set.set_defaults(handler=command_telemetry_config)
|
|
899
|
+
|
|
900
|
+
daemon = subparsers.add_parser(
|
|
901
|
+
"daemon", help="BugX 自治持续挖掘常驻守护进程管理",
|
|
902
|
+
)
|
|
903
|
+
daemon_sub = daemon.add_subparsers(dest="daemon_action", required=True)
|
|
904
|
+
d_start = daemon_sub.add_parser("start", help="启动常驻守护进程")
|
|
905
|
+
d_start.add_argument("--root", type=Path, default=Path.cwd(), help="项目根目录")
|
|
906
|
+
d_start.add_argument("--foreground", action="store_true", help="前台运行")
|
|
907
|
+
d_start.add_argument("--max-wall-time", type=float, default=14400.0, help="单次 Session 软预算检测窗口(秒)")
|
|
908
|
+
d_start.add_argument("--interval", type=float, default=5.0, help="调度巡检间隔(秒)")
|
|
909
|
+
d_start.set_defaults(handler=command_daemon)
|
|
910
|
+
|
|
911
|
+
d_stop = daemon_sub.add_parser("stop", help="停止常驻守护进程")
|
|
912
|
+
d_stop.add_argument("--root", type=Path, default=Path.cwd(), help="项目根目录")
|
|
913
|
+
d_stop.add_argument("--force", action="store_true", help="强制终止")
|
|
914
|
+
d_stop.set_defaults(handler=command_daemon)
|
|
915
|
+
|
|
916
|
+
d_status = daemon_sub.add_parser("status", help="查询守护进程状态与健康度")
|
|
917
|
+
d_status.add_argument("--root", type=Path, default=Path.cwd(), help="项目根目录")
|
|
918
|
+
d_status.add_argument("--json", action="store_true", help="输出 JSON 格式")
|
|
919
|
+
d_status.set_defaults(handler=command_daemon)
|
|
920
|
+
|
|
921
|
+
d_attach = daemon_sub.add_parser("attach", help="热回显并连接常驻日志输出")
|
|
922
|
+
d_attach.add_argument("--root", type=Path, default=Path.cwd(), help="项目根目录")
|
|
923
|
+
d_attach.add_argument("-n", "--lines", type=int, default=50, help="初始回显行数")
|
|
924
|
+
d_attach.set_defaults(handler=command_daemon)
|
|
925
|
+
|
|
926
|
+
# 宿主清单与并发区间都来自插件事实(``worker_runtime.autonomous_cli`` /
|
|
927
|
+
# ``concurrency_bounds``),参数层不再写宿主名。
|
|
928
|
+
autonomous_hosts = autonomous_host_names()
|
|
929
|
+
autonomous_labels = "/".join(engine_host_label(name) for name in autonomous_hosts)
|
|
930
|
+
process_pool_host = next(
|
|
931
|
+
(name for name in autonomous_hosts if engine_host_concurrency_bounds(name)), "",
|
|
932
|
+
)
|
|
933
|
+
final_bounds = engine_host_concurrency_bounds(process_pool_host)
|
|
934
|
+
workers_help = (
|
|
935
|
+
f"{engine_host_label(process_pool_host)} CLI 进程池并发度"
|
|
936
|
+
f"({final_bounds[0]}~{final_bounds[1]});0 表示按 Supervisor 自适应容量"
|
|
937
|
+
if final_bounds
|
|
938
|
+
else "进程池并发度;0 表示按 Supervisor 自适应容量"
|
|
939
|
+
)
|
|
940
|
+
autonomous_cmd = subparsers.add_parser(
|
|
941
|
+
"autonomous", help=f"显式启动 {autonomous_labels} 前台无人值守挖掘",
|
|
942
|
+
)
|
|
943
|
+
autonomous_cmd.add_argument("--root", type=Path, default=Path.cwd(), help="项目根目录")
|
|
944
|
+
autonomous_cmd.add_argument("--host", choices=autonomous_hosts, required=True,
|
|
945
|
+
help="宿主 Agent;不自动猜测")
|
|
946
|
+
autonomous_cmd.add_argument(
|
|
947
|
+
"--workers", type=int, default=0,
|
|
948
|
+
help=workers_help,
|
|
949
|
+
)
|
|
950
|
+
autonomous_cmd.add_argument(
|
|
951
|
+
"--model", type=str, default="",
|
|
952
|
+
help="指定宿主调用的模型 ID(如 gpt-4o、deepseek-chat 等);缺省时自动使用宿主已配置的同款自定义模型",
|
|
953
|
+
)
|
|
954
|
+
autonomous_cmd.add_argument(
|
|
955
|
+
"--provider", type=str, default="",
|
|
956
|
+
help="指定宿主调用的 Provider ID(如 openai-compatible、deepseek 等);缺省时自动读取宿主已配置的 Provider",
|
|
957
|
+
)
|
|
958
|
+
autonomous_cmd.add_argument(
|
|
959
|
+
"--max-turns", type=int, default=0,
|
|
960
|
+
help="宿主回合上限;0 表示持续恢复同一会话,直到权威运行态完成或硬失败",
|
|
961
|
+
)
|
|
962
|
+
autonomous_cmd.add_argument(
|
|
963
|
+
"--max-wall-time", type=float, default=0.0,
|
|
964
|
+
help="宿主墙钟上限(秒);0 表示持续运行,直到权威运行态完成或硬失败",
|
|
965
|
+
)
|
|
966
|
+
autonomous_cmd.add_argument(
|
|
967
|
+
"--agent-timeout", type=float, default=600.0,
|
|
968
|
+
help="单次宿主回合无进展上限(秒);supervisor 心跳新鲜的回合自动滑动续期(硬上限 8 倍),心跳静默超时后读取权威状态并自动恢复,默认 600",
|
|
969
|
+
)
|
|
970
|
+
autonomous_cmd.add_argument(
|
|
971
|
+
"--coverage-manifest", type=Path, default=None,
|
|
972
|
+
help=(
|
|
973
|
+
"显式覆盖清单(Markdown 表格):把本轮审计范围限定为清单里的单元,"
|
|
974
|
+
"不 reconcile 到全仓。大仓/引擎自审/带 vendored 目录的项目必须用它,"
|
|
975
|
+
"否则清单门禁会把全仓文件都当单元"
|
|
976
|
+
),
|
|
977
|
+
)
|
|
978
|
+
autonomous_cmd.add_argument(
|
|
979
|
+
"--no-adaptive-wall-time", action="store_false", dest="adaptive_wall_time", default=True,
|
|
980
|
+
help="关闭根据进展与复杂度自适应动态延长墙钟预算(默认开启)",
|
|
981
|
+
)
|
|
982
|
+
autonomous_cmd.add_argument(
|
|
983
|
+
"--adaptive-baseline", action="store_true", default=False,
|
|
984
|
+
help="在未显式指定 --max-wall-time 时,依据覆盖清单与单元规模自动估算初始基准墙钟时间",
|
|
985
|
+
)
|
|
986
|
+
autonomous_cmd.add_argument("--json", action="store_true")
|
|
987
|
+
autonomous_cmd.set_defaults(handler=command_autonomous)
|
|
988
|
+
|
|
989
|
+
goal_cmd = subparsers.add_parser(
|
|
990
|
+
"goal", help="目标导向无人值守自治挖掘与长程自愈循环",
|
|
991
|
+
)
|
|
992
|
+
goal_cmd.add_argument("target_description", nargs="?", default="", help="目标描述或指定范围")
|
|
993
|
+
goal_cmd.add_argument("--root", type=Path, default=Path.cwd(), help="项目根目录")
|
|
994
|
+
# 可选宿主与 autonomous 同源(插件声明 + 未迁移基线),不再写第二份清单。
|
|
995
|
+
goal_cmd.add_argument("--host", choices=autonomous_hosts, default="claude",
|
|
996
|
+
help="宿主 Agent (默认 claude)")
|
|
997
|
+
goal_cmd.add_argument("--target-coverage", type=float, default=100.0,
|
|
998
|
+
help="目标覆盖率百分比 (0.0~100.0,默认 100.0)")
|
|
999
|
+
goal_cmd.add_argument("--allow-open-findings", action="store_true",
|
|
1000
|
+
help="允许存在未闭环漏洞即收敛(默认必须零遗留漏洞)")
|
|
1001
|
+
goal_cmd.add_argument("--disallow-quarantine", action="store_true",
|
|
1002
|
+
help="禁止隔离坏单元(默认开启 3-strike 坏单元隔离)")
|
|
1003
|
+
goal_cmd.add_argument(
|
|
1004
|
+
"--max-turns", type=int, default=0,
|
|
1005
|
+
help="宿主回合上限;0 表示持续推进,直到达成目标或硬失败",
|
|
1006
|
+
)
|
|
1007
|
+
goal_cmd.add_argument(
|
|
1008
|
+
"--max-wall-time", type=float, default=14400.0,
|
|
1009
|
+
help="全局最大硬超时(秒);默认 14400 (4小时),0 表示无限制",
|
|
1010
|
+
)
|
|
1011
|
+
goal_cmd.add_argument(
|
|
1012
|
+
"--agent-timeout", type=float, default=600.0,
|
|
1013
|
+
help="单次回合无进展上限(秒);supervisor 心跳新鲜的回合自动滑动续期(硬上限 8 倍),默认 600",
|
|
1014
|
+
)
|
|
1015
|
+
goal_cmd.add_argument(
|
|
1016
|
+
"--max-unit-retries", type=int, default=3,
|
|
1017
|
+
help="单单元最大连续失败重试次数,超限进入隔离区,默认 3",
|
|
1018
|
+
)
|
|
1019
|
+
goal_cmd.add_argument(
|
|
1020
|
+
"--max-transient-retries", type=int, default=5,
|
|
1021
|
+
help="最大连续瞬态错误自愈重试次数,默认 5",
|
|
1022
|
+
)
|
|
1023
|
+
goal_cmd.add_argument("--json", action="store_true", help="JSON 格式输出")
|
|
1024
|
+
goal_cmd.set_defaults(handler=command_goal)
|
|
1025
|
+
|
|
1026
|
+
sup = subparsers.add_parser(
|
|
1027
|
+
"supervisor",
|
|
1028
|
+
help=(
|
|
1029
|
+
"本地监督 MCP:install / status / rpc;"
|
|
1030
|
+
"带外动作:reset-budget / recover / rebind-target / gate / findings"
|
|
1031
|
+
),
|
|
1032
|
+
)
|
|
1033
|
+
sup.add_argument(
|
|
1034
|
+
"supervisor_command",
|
|
1035
|
+
choices=(
|
|
1036
|
+
"install", "status", "rpc",
|
|
1037
|
+
# 带外动作白名单由 commands.system 单一真源派生(恢复 + 数据修复):
|
|
1038
|
+
# 此处不再复制枚举,避免「帮助列出但 dispatch 拒绝」的静默漂移。
|
|
1039
|
+
*system.SUPERVISOR_PASSTHROUGH_ACTIONS,
|
|
1040
|
+
),
|
|
1041
|
+
)
|
|
1042
|
+
sup.add_argument("--root", type=Path, default=Path.cwd())
|
|
1043
|
+
sup.add_argument("supervisor_args", nargs=argparse.REMAINDER, default=[])
|
|
1044
|
+
sup.set_defaults(handler=command_supervisor)
|
|
1045
|
+
|
|
1046
|
+
plugin = subparsers.add_parser(
|
|
1047
|
+
"plugin", help="安装、校验或查看私有 BugX 插件(不执行插件)",
|
|
1048
|
+
)
|
|
1049
|
+
plugin.add_argument(
|
|
1050
|
+
"plugin_command",
|
|
1051
|
+
choices=("list", "status", "install", "uninstall", "zcode"),
|
|
1052
|
+
)
|
|
1053
|
+
plugin.add_argument("plugin_name", nargs="?")
|
|
1054
|
+
plugin.add_argument("--root", type=Path, default=Path.cwd())
|
|
1055
|
+
plugin.add_argument("--source", type=Path)
|
|
1056
|
+
plugin.add_argument("--force", action="store_true")
|
|
1057
|
+
plugin.add_argument(
|
|
1058
|
+
"--remove", action="store_true",
|
|
1059
|
+
help="plugin zcode:从 ZCode plugins.dirs 移除本项目插件目录",
|
|
1060
|
+
)
|
|
1061
|
+
plugin.add_argument("--json", action="store_true")
|
|
1062
|
+
plugin.add_argument("--yes", action="store_true", help="确认插件卸载")
|
|
1063
|
+
plugin.set_defaults(handler=command_plugin)
|
|
1064
|
+
|
|
1065
|
+
# ── update:自动更新 ──
|
|
1066
|
+
update_parser = subparsers.add_parser(
|
|
1067
|
+
"update", help="检查并安装最新 BugX CLI 版本",
|
|
1068
|
+
)
|
|
1069
|
+
update_parser.add_argument("--root", type=Path, default=Path.cwd())
|
|
1070
|
+
update_parser.add_argument(
|
|
1071
|
+
"--check", action="store_true",
|
|
1072
|
+
help="只检查版本,不下载或安装",
|
|
1073
|
+
)
|
|
1074
|
+
update_parser.add_argument(
|
|
1075
|
+
"--force", action="store_true",
|
|
1076
|
+
help="即使已是最新版本也强制重新安装",
|
|
1077
|
+
)
|
|
1078
|
+
update_parser.add_argument(
|
|
1079
|
+
"--repair-assets", action="store_true",
|
|
1080
|
+
help="从已验证的 stable wheel 恢复缺失的 CLI 安装资源",
|
|
1081
|
+
)
|
|
1082
|
+
update_parser.add_argument(
|
|
1083
|
+
"--allow-downgrade", action="store_true",
|
|
1084
|
+
help="允许服务端版本低于当前版本时执行回退(服务器版本回退场景)",
|
|
1085
|
+
)
|
|
1086
|
+
update_parser.add_argument(
|
|
1087
|
+
"--channel", "-c", type=str, default="",
|
|
1088
|
+
choices=["stable", "alpha", ""],
|
|
1089
|
+
help="指定发布通道:stable 或 alpha(默认使用 stable 稳定通道)",
|
|
1090
|
+
)
|
|
1091
|
+
update_parser.set_defaults(handler=command_update)
|
|
1092
|
+
|
|
1093
|
+
# ── patch-forge:静态补丁包 ──
|
|
1094
|
+
patch_parser = subparsers.add_parser(
|
|
1095
|
+
"patch-forge", help="生成或静态校验补丁包(不执行包内代码、不提交远端)",
|
|
1096
|
+
)
|
|
1097
|
+
patch_mode = patch_parser.add_mutually_exclusive_group(required=False)
|
|
1098
|
+
patch_mode.add_argument("--from-issue", help="issue/spec Markdown 路径(相对 --root)")
|
|
1099
|
+
patch_mode.add_argument("--verify", help="只静态校验已有补丁包目录")
|
|
1100
|
+
patch_mode.add_argument("--status", help="查询远程补丁验证记录 ID")
|
|
1101
|
+
patch_parser.add_argument("--root", type=Path, default=Path.cwd())
|
|
1102
|
+
patch_parser.add_argument("--kind", choices=("engine",), help="补丁对象:仅允许 BugX 自身引擎代码")
|
|
1103
|
+
patch_parser.add_argument("--base-version", default=__version__)
|
|
1104
|
+
patch_parser.add_argument("--patch-id", default=None)
|
|
1105
|
+
patch_parser.add_argument("--diff", action="append", default=[])
|
|
1106
|
+
patch_parser.add_argument("--repro", action="append", default=[])
|
|
1107
|
+
patch_parser.add_argument("--test", action="append", default=[])
|
|
1108
|
+
patch_parser.add_argument("--signature")
|
|
1109
|
+
patch_parser.add_argument("--severity", choices=("high", "medium", "low", "info"))
|
|
1110
|
+
patch_parser.add_argument("--output")
|
|
1111
|
+
patch_parser.add_argument("--dry-run", action="store_true")
|
|
1112
|
+
patch_parser.add_argument("--json", action="store_true")
|
|
1113
|
+
patch_parser.add_argument("--submit", action="store_true", help="生成后提交远程静态验证(显式副作用)")
|
|
1114
|
+
patch_parser.add_argument("--api-key", help="远程补丁验证专用 API key(默认读取环境变量)")
|
|
1115
|
+
patch_parser.add_argument("--base-url", help="远程云端基址")
|
|
1116
|
+
patch_parser.add_argument("--source-commit", default="", help="绑定 Jenkins/源仓库提交 SHA")
|
|
1117
|
+
patch_parser.add_argument("--spec-only", action="store_true")
|
|
1118
|
+
patch_parser.add_argument("--session-id", "--session", dest="session_id")
|
|
1119
|
+
patch_parser.add_argument("--run-id")
|
|
1120
|
+
patch_parser.add_argument("--lifecycle-id")
|
|
1121
|
+
patch_parser.add_argument("--repository")
|
|
1122
|
+
patch_parser.add_argument("--finding-fingerprint", action="append", default=[])
|
|
1123
|
+
patch_parser.add_argument(
|
|
1124
|
+
"--test-red-green", action="store_true",
|
|
1125
|
+
help="执行本地红绿闭环受限验证(repro 失败 -> 补丁应用 -> repro 消除 -> tests 通过)",
|
|
1126
|
+
)
|
|
1127
|
+
patch_parser.set_defaults(handler=command_patch_forge)
|
|
1128
|
+
|
|
1129
|
+
# ── log:诊断日志分析与瀑布图 ──
|
|
1130
|
+
log_parser = subparsers.add_parser(
|
|
1131
|
+
"log", help="查看诊断日志、错误排查、链路追踪与耗时瀑布图",
|
|
1132
|
+
)
|
|
1133
|
+
log_parser.add_argument("--root", type=Path, default=Path.cwd(), help="项目根目录")
|
|
1134
|
+
log_parser.add_argument(
|
|
1135
|
+
"--tail", nargs="?", const=20, type=int, default=None,
|
|
1136
|
+
help="显示最新 N 条日志(默认 20 条)",
|
|
1137
|
+
)
|
|
1138
|
+
log_parser.add_argument(
|
|
1139
|
+
"--watch", "-f", "--follow", action="store_true", dest="watch",
|
|
1140
|
+
help="实时流式监听日志新增记录(支持 Ctrl-C 退出)",
|
|
1141
|
+
)
|
|
1142
|
+
log_parser.add_argument(
|
|
1143
|
+
"--errors", action="store_true",
|
|
1144
|
+
help="仅显示警告、错误日志及异常堆栈",
|
|
1145
|
+
)
|
|
1146
|
+
log_parser.add_argument(
|
|
1147
|
+
"--trace", type=str, default=None,
|
|
1148
|
+
help="按 trace_id 聚合检索执行链路流水",
|
|
1149
|
+
)
|
|
1150
|
+
log_parser.add_argument(
|
|
1151
|
+
"--timing", "--waterfall", action="store_true", dest="timing",
|
|
1152
|
+
help="生成阶段耗时与 Token 消耗双轨 ASCII 瀑布图",
|
|
1153
|
+
)
|
|
1154
|
+
log_parser.add_argument(
|
|
1155
|
+
"--timeline", "--replay", action="store_true", dest="timeline",
|
|
1156
|
+
help="回放对话与操作每一步执行流(含耗时、状态与摘要)",
|
|
1157
|
+
)
|
|
1158
|
+
log_parser.add_argument(
|
|
1159
|
+
"--anomalies", "--audit", action="store_true", dest="anomalies",
|
|
1160
|
+
help="智能审计耗时异常、慢命令、高危扫描与死循环",
|
|
1161
|
+
)
|
|
1162
|
+
log_parser.add_argument(
|
|
1163
|
+
"--tokens", action="store_true",
|
|
1164
|
+
help="按 Token 消耗量排名展示阶段贡献度排行榜",
|
|
1165
|
+
)
|
|
1166
|
+
log_parser.add_argument(
|
|
1167
|
+
"--bundle", action="store_true",
|
|
1168
|
+
help="生成一键脱敏诊断打包文件 (.tar.gz)",
|
|
1169
|
+
)
|
|
1170
|
+
log_parser.add_argument(
|
|
1171
|
+
"--mcp-polling", action="store_true",
|
|
1172
|
+
help="输出 tools/list 服务端缓存命中与外部轮询间隔诊断(不证明客户端已缓存)",
|
|
1173
|
+
)
|
|
1174
|
+
log_parser.add_argument(
|
|
1175
|
+
"--json", action="store_true",
|
|
1176
|
+
help="以 JSON 输出诊断结果",
|
|
1177
|
+
)
|
|
1178
|
+
log_parser.add_argument(
|
|
1179
|
+
"--output", "-o", type=Path, default=None,
|
|
1180
|
+
help="指定诊断包导出路径",
|
|
1181
|
+
)
|
|
1182
|
+
log_parser.set_defaults(handler=command_log)
|
|
1183
|
+
|
|
1184
|
+
# ── stats:全局与跨项目时间与 Token 计量统计看板 (DOC-049) ──
|
|
1185
|
+
stats_parser = subparsers.add_parser(
|
|
1186
|
+
"stats", help="查看全局跨项目时间与 Token 消耗治理看板",
|
|
1187
|
+
)
|
|
1188
|
+
stats_parser.add_argument(
|
|
1189
|
+
"--global", action="store_true", dest="global_mode",
|
|
1190
|
+
help="查看全机跨项目全局时间、Token 与 ROI 统计看板",
|
|
1191
|
+
)
|
|
1192
|
+
stats_parser.add_argument(
|
|
1193
|
+
"--days", type=int, default=30,
|
|
1194
|
+
help="统计时间窗口(天数,默认 30 天)",
|
|
1195
|
+
)
|
|
1196
|
+
stats_parser.add_argument(
|
|
1197
|
+
"--json", action="store_true",
|
|
1198
|
+
help="以 JSON 格式输出统计指标",
|
|
1199
|
+
)
|
|
1200
|
+
stats_parser.set_defaults(handler=command_stats)
|
|
1201
|
+
|
|
1202
|
+
# ── project:工程代码体量、技术栈画像与规模估模分析 ──
|
|
1203
|
+
project_parser = subparsers.add_parser(
|
|
1204
|
+
"project", help="工程代码体量、技术栈画像与规模估模分析",
|
|
1205
|
+
)
|
|
1206
|
+
project_sub = project_parser.add_subparsers(dest="project_action")
|
|
1207
|
+
|
|
1208
|
+
p_analyze = project_sub.add_parser("analyze", help="全景扫描并分析当前或指定工程的代码体量与画像")
|
|
1209
|
+
p_analyze.add_argument("--root", type=Path, default=Path.cwd(), help="项目根目录(默认当前目录)")
|
|
1210
|
+
p_analyze.add_argument("--json", action="store_true", help="以结构化 JSON 输出")
|
|
1211
|
+
p_analyze.set_defaults(handler=command_project)
|
|
1212
|
+
|
|
1213
|
+
p_show = project_sub.add_parser("show", help="查看已缓存的项目画像与度量")
|
|
1214
|
+
p_show.add_argument("--root", type=Path, default=Path.cwd(), help="项目根目录(默认当前目录)")
|
|
1215
|
+
p_show.add_argument("--json", action="store_true", help="以结构化 JSON 输出")
|
|
1216
|
+
p_show.set_defaults(handler=command_project)
|
|
1217
|
+
|
|
1218
|
+
p_sync = project_sub.add_parser("sync", help="将项目画像与代码指标同步至云端看板")
|
|
1219
|
+
p_sync.add_argument("--root", type=Path, default=Path.cwd(), help="项目根目录(默认当前目录)")
|
|
1220
|
+
p_sync.add_argument("--json", action="store_true", help="以结构化 JSON 输出")
|
|
1221
|
+
p_sync.set_defaults(handler=command_project)
|
|
1222
|
+
|
|
1223
|
+
p_list = project_sub.add_parser("list", help="查看全局所有受管工程列表 (~/.bugx/projects.json)")
|
|
1224
|
+
p_list.add_argument("--root", type=Path, default=Path.cwd(), help="当前工作区根目录")
|
|
1225
|
+
p_list.add_argument("--json", action="store_true", help="以结构化 JSON 输出")
|
|
1226
|
+
p_list.set_defaults(handler=command_project)
|
|
1227
|
+
|
|
1228
|
+
p_refresh = project_sub.add_parser("refresh", help="全量扫描并刷新全局受管工程列表 (~/.bugx/projects.json)")
|
|
1229
|
+
p_refresh.add_argument("--root", type=Path, default=Path.cwd(), help="当前工作区根目录")
|
|
1230
|
+
p_refresh.add_argument("--json", action="store_true", help="以结构化 JSON 输出")
|
|
1231
|
+
p_refresh.set_defaults(handler=command_project)
|
|
1232
|
+
|
|
1233
|
+
p_rebind = project_sub.add_parser(
|
|
1234
|
+
"rebind",
|
|
1235
|
+
help="诊断或迁移 .bugx 的项目身份(项目目录搬移/改名后使用)",
|
|
1236
|
+
)
|
|
1237
|
+
p_rebind.add_argument("--root", type=Path, default=Path.cwd(), help="项目根目录(默认当前目录)")
|
|
1238
|
+
p_rebind.add_argument(
|
|
1239
|
+
"--migrate", action="store_true",
|
|
1240
|
+
help="把盘上 project_id 重写为当前路径指纹并保留 project_uid(确认是搬移而非误用他人布局)",
|
|
1241
|
+
)
|
|
1242
|
+
p_rebind.add_argument("--json", action="store_true", help="以结构化 JSON 输出")
|
|
1243
|
+
p_rebind.set_defaults(handler=command_project)
|
|
1244
|
+
|
|
1245
|
+
p_settings = project_sub.add_parser("settings", help="查看或修改项目的门禁配置、挖掘情报、MCP 与 Skill")
|
|
1246
|
+
p_settings.add_argument("target", nargs="?", default=None, help="目标工程路径或工程 Hash(默认当前工作区)")
|
|
1247
|
+
p_settings.add_argument("--root", type=Path, default=Path.cwd(), help="当前工作区根目录")
|
|
1248
|
+
p_settings.add_argument("--set-cloud-sync", choices=["on", "off"], default=None, help="设置是否开启云端同步")
|
|
1249
|
+
p_settings.add_argument("--set-review", choices=["auto", "interactive", "off"], default=None, help="设置审查执行模式")
|
|
1250
|
+
p_settings.add_argument("--set-polling", choices=["auto", "manual", "off"], default=None, help="设置漏洞轮询策略")
|
|
1251
|
+
p_settings.add_argument("--set-auto-fix", choices=["on", "off", "confirm"], default=None, help="设置是否自动修改代码")
|
|
1252
|
+
p_settings.add_argument("--set-commit", choices=["round", "task", "off"], default=None, help="设置代码自动提交策略")
|
|
1253
|
+
p_settings.add_argument("--json", action="store_true", help="以结构化 JSON 输出")
|
|
1254
|
+
p_settings.set_defaults(handler=command_project)
|
|
1255
|
+
|
|
1256
|
+
project_parser.set_defaults(project_action="analyze", handler=command_project)
|
|
1257
|
+
project_parser.add_argument("--root", type=Path, default=Path.cwd(), help="项目根目录(默认当前目录)")
|
|
1258
|
+
project_parser.add_argument("--json", action="store_true", help="以结构化 JSON 输出")
|
|
1259
|
+
|
|
1260
|
+
# ── view:安全查看源文件切片与视窗(DOC-225,具越界自愈与沙箱隔离)──
|
|
1261
|
+
view_parser = subparsers.add_parser(
|
|
1262
|
+
"view", help="安全查看源文件切片与视窗(具备越界自愈与沙箱隔离)",
|
|
1263
|
+
)
|
|
1264
|
+
view_parser.add_argument("path", help="待查看的文件路径")
|
|
1265
|
+
view_parser.add_argument(
|
|
1266
|
+
"--lines", "-L", default="1:200",
|
|
1267
|
+
help="行范围,例如 42:90、42-90 或 50(默认 1:200)",
|
|
1268
|
+
)
|
|
1269
|
+
view_parser.add_argument(
|
|
1270
|
+
"--no-numbers", "-N", action="store_true",
|
|
1271
|
+
help="不显示行号前缀",
|
|
1272
|
+
)
|
|
1273
|
+
view_parser.add_argument(
|
|
1274
|
+
"--json", action="store_true",
|
|
1275
|
+
help="以 JSON 结构化格式输出",
|
|
1276
|
+
)
|
|
1277
|
+
view_parser.add_argument(
|
|
1278
|
+
"--root", type=Path, default=None,
|
|
1279
|
+
help="项目根目录(用于沙箱白名单)",
|
|
1280
|
+
)
|
|
1281
|
+
view_parser.add_argument(
|
|
1282
|
+
"--max-lines", type=int, default=500,
|
|
1283
|
+
help="单次最大读取行数(默认 500)",
|
|
1284
|
+
)
|
|
1285
|
+
view_parser.set_defaults(handler=command_view)
|
|
1286
|
+
|
|
1287
|
+
# ── test-generate:全息自动化测试脚手架生成 ──
|
|
1288
|
+
tg_parser = subparsers.add_parser(
|
|
1289
|
+
"test-generate", help="为指定单元自动生成标准化 AAA 测试用例或自包含 PoC",
|
|
1290
|
+
)
|
|
1291
|
+
tg_parser.add_argument("--root", type=Path, default=Path.cwd(), help="项目根路径")
|
|
1292
|
+
tg_parser.add_argument("--scope", required=True, help="被测单元符号范围,如 path/foo.py::func")
|
|
1293
|
+
tg_parser.add_argument("--techniques", default="boundary,negative-control", help="测试策略逗号列表")
|
|
1294
|
+
tg_parser.add_argument("--out", type=Path, help="输出文件路径")
|
|
1295
|
+
tg_parser.add_argument("--standalone", action="store_true", help="生成自包含 0/1 PoC 验证脚本")
|
|
1296
|
+
tg_parser.add_argument("--assert-expr", default="", help="成功结果断言表达式;测试套件中可引用 res")
|
|
1297
|
+
tg_parser.add_argument("--expected-exc", default="", help="测试套件/PoC 的预期异常类名")
|
|
1298
|
+
tg_parser.add_argument("--json", action="store_true")
|
|
1299
|
+
tg_parser.set_defaults(handler=command_test_generate)
|
|
1300
|
+
|
|
1301
|
+
# ── test-audit:测试用例四维质量量化审计 ──
|
|
1302
|
+
ta_parser = subparsers.add_parser(
|
|
1303
|
+
"test-audit", help="对测试用例进行四维(准确、完整、有效、全面)量化质量审计",
|
|
1304
|
+
)
|
|
1305
|
+
ta_parser.add_argument("file", type=Path, help="待审计测试源文件路径")
|
|
1306
|
+
ta_parser.add_argument("--scope", default="", help="被测单元符号范围")
|
|
1307
|
+
ta_parser.add_argument("--min-score", type=float, default=70.0, help="最低质量准入得分")
|
|
1308
|
+
ta_parser.add_argument("--strict", action="store_true", help="严格模式:有违规即退出 1")
|
|
1309
|
+
ta_parser.add_argument("--json", action="store_true")
|
|
1310
|
+
ta_parser.set_defaults(handler=command_test_audit)
|
|
1311
|
+
|
|
1312
|
+
# ── mining-audit:挖掘方案与用例全息质量审计 ──
|
|
1313
|
+
ma_parser = subparsers.add_parser(
|
|
1314
|
+
"mining-audit", help="对漏洞挖掘方案与用例进行四维(准确、完整、有效、全面)质量量化审计与加固",
|
|
1315
|
+
)
|
|
1316
|
+
ma_sub = ma_parser.add_subparsers(dest="mining_subcommand", required=True)
|
|
1317
|
+
|
|
1318
|
+
ma_p_audit = ma_sub.add_parser("audit", help="量化审计挖掘方案")
|
|
1319
|
+
ma_p_audit.add_argument("plan_file", type=Path, help="挖掘方案 JSON 文件路径")
|
|
1320
|
+
ma_p_audit.add_argument("--root", type=Path, default=Path.cwd(), help="项目根路径")
|
|
1321
|
+
ma_p_audit.add_argument("--min-score", type=float, default=80.0, help="最低通过分数(默认 80.0)")
|
|
1322
|
+
ma_p_audit.add_argument("--strict", action="store_true", help="严格模式(有违规项即阻断)")
|
|
1323
|
+
ma_p_audit.add_argument(
|
|
1324
|
+
"--allow-degraded", action="store_true",
|
|
1325
|
+
help="明确接受降级方案;否则 DEGRADED 退出码为 2,要求先取得用户决策",
|
|
1326
|
+
)
|
|
1327
|
+
ma_p_audit.add_argument("--json", action="store_true")
|
|
1328
|
+
ma_p_audit.set_defaults(handler=command_mining_audit)
|
|
1329
|
+
|
|
1330
|
+
ma_p_explore = ma_sub.add_parser("explore", help="勘测项目可挖掘功能主体(多语种 AST/Web路由/CLI/反序列化/临界区)")
|
|
1331
|
+
ma_p_explore.add_argument("--root", type=Path, default=Path.cwd(), help="项目根路径")
|
|
1332
|
+
ma_p_explore.add_argument("--language", help="显式指定扫描语言;省略时按文件扩展名识别")
|
|
1333
|
+
ma_p_explore.add_argument("--json", action="store_true")
|
|
1334
|
+
ma_p_explore.set_defaults(handler=command_mining_audit)
|
|
1335
|
+
|
|
1336
|
+
ma_p_harden = ma_sub.add_parser("harden", help="自动加固补全挖掘方案")
|
|
1337
|
+
ma_p_harden.add_argument("plan_file", type=Path, help="待加固挖掘方案 JSON 文件")
|
|
1338
|
+
ma_p_harden.add_argument("--root", type=Path, default=Path.cwd(), help="项目根路径")
|
|
1339
|
+
ma_p_harden.add_argument("--out", type=Path, help="加固后保存路径")
|
|
1340
|
+
ma_p_harden.set_defaults(handler=command_mining_audit)
|
|
1341
|
+
ma_parser.set_defaults(handler=command_mining_audit)
|
|
1342
|
+
|
|
1343
|
+
# ── test-verify:测试用例能力动态验证框架 ──
|
|
1344
|
+
tv_parser = subparsers.add_parser(
|
|
1345
|
+
"test-verify", help="基于 AST 语义变异与沙箱隔离动态验证测试用例的抓 Bug 杀伤能力",
|
|
1346
|
+
)
|
|
1347
|
+
tv_sub = tv_parser.add_subparsers(dest="verify_subcommand", required=True)
|
|
1348
|
+
|
|
1349
|
+
tv_p_verify = tv_sub.add_parser("verify", help="动态验证测试用例对目标代码的变异杀伤能力")
|
|
1350
|
+
tv_p_verify.add_argument("--target", required=True, help="被测源码文件路径 (例如 core/foo.py)")
|
|
1351
|
+
tv_p_verify.add_argument("--test", required=True, help="测试用例模块或路径 (例如 tests/test_foo.py)")
|
|
1352
|
+
tv_p_verify.add_argument("--root", type=Path, default=Path.cwd(), help="项目根路径")
|
|
1353
|
+
tv_p_verify.add_argument("--max-mutants", type=int, default=30, help="最大变异体数量 (默认 30)")
|
|
1354
|
+
tv_p_verify.add_argument("--timeout", type=float, default=2.0, help="单次变异测试超时秒数 (默认 2.0s)")
|
|
1355
|
+
tv_p_verify.add_argument("--strict", action="store_true", help="严格门禁模式 (击杀率 < 60%% 时非零退出)")
|
|
1356
|
+
tv_p_verify.add_argument("--json", action="store_true")
|
|
1357
|
+
tv_p_verify.set_defaults(handler=command_test_verify)
|
|
1358
|
+
|
|
1359
|
+
tv_p_mutate = tv_sub.add_parser("mutate", help="仅生成并预览 AST 变异体")
|
|
1360
|
+
tv_p_mutate.add_argument("--target", required=True, help="目标源码路径")
|
|
1361
|
+
tv_p_mutate.add_argument("--root", type=Path, default=Path.cwd(), help="项目根路径")
|
|
1362
|
+
tv_p_mutate.add_argument("--max-mutants", type=int, default=30, help="最大变异体数量")
|
|
1363
|
+
tv_p_mutate.add_argument("--json", action="store_true")
|
|
1364
|
+
tv_p_mutate.set_defaults(handler=command_test_verify)
|
|
1365
|
+
tv_parser.set_defaults(handler=command_test_verify)
|
|
1366
|
+
|
|
1367
|
+
# ── audit:项目级一键全息攻防渗透审计、Artifact Graph 编排与双轨报告交付 ──
|
|
1368
|
+
audit.register_parser(subparsers)
|
|
1369
|
+
|
|
1370
|
+
# ── interaction:非交互宿主的启动门禁答案回灌通道 ──
|
|
1371
|
+
interaction.register_parser(subparsers)
|
|
1372
|
+
|
|
1373
|
+
# ── advisory:GitHub Security Advisory (GHSA) 标准公告与 PR 草稿 ──
|
|
1374
|
+
adv_parser = subparsers.add_parser("advisory", help="GitHub Security Advisory (GHSA) 标准安全公告与 PR 修复草案管理")
|
|
1375
|
+
adv_sub = adv_parser.add_subparsers(dest="advisory_command")
|
|
1376
|
+
adv_list = adv_sub.add_parser("list", help="查看已注册的 GHSA 安全公告")
|
|
1377
|
+
adv_list.add_argument("--json", action="store_true")
|
|
1378
|
+
adv_list.set_defaults(handler=command_advisory)
|
|
1379
|
+
|
|
1380
|
+
adv_export = adv_sub.add_parser("export", help="导出指定漏洞的标准化 GHSA 安全公告与 PR 修复草稿")
|
|
1381
|
+
adv_export.add_argument("--cve", default="CVE-2026-9001", help="CVE 编号 (默认 CVE-2026-9001)")
|
|
1382
|
+
adv_export.add_argument("--package", default="target-package", help="受影响软件包名称")
|
|
1383
|
+
adv_export.add_argument("--ecosystem", default="npm", help="软件包生态 (npm, Maven, PyPI, crates.io, Composer, etc.)")
|
|
1384
|
+
adv_export.add_argument("--category", default="generic_logic", help="漏洞威胁类别")
|
|
1385
|
+
adv_export.add_argument("--symbol", default="processInput", help="受影响函数或方法符号")
|
|
1386
|
+
adv_export.add_argument("--target", default="src/core.py", help="受影响源文件路径")
|
|
1387
|
+
adv_export.add_argument("--format", choices=("markdown", "json"), default="markdown", help="输出格式 (markdown, json)")
|
|
1388
|
+
adv_export.add_argument("--out", type=Path, help="保存文件路径")
|
|
1389
|
+
adv_export.set_defaults(handler=command_advisory)
|
|
1390
|
+
adv_parser.set_defaults(handler=command_advisory)
|
|
1391
|
+
|
|
1392
|
+
# ── report:双轨制人性化安全报告生成器 (formal 商务正式报告, visual 高颜值技术报告) ──
|
|
1393
|
+
rep_parser = subparsers.add_parser("report", help="双轨制人性化安全审计报告生成器 (formal 商务正式, visual 高颜值交付)")
|
|
1394
|
+
rep_sub = rep_parser.add_subparsers(dest="report_type")
|
|
1395
|
+
|
|
1396
|
+
report_source_help = (
|
|
1397
|
+
"报告数据来源:project=项目运行态 Supervisor 权威 findings(默认);"
|
|
1398
|
+
"eval=--eval-dir 下的引擎自测收据;auto=优先项目运行态、不可用时退回收据"
|
|
1399
|
+
)
|
|
1400
|
+
|
|
1401
|
+
def _add_report_source_args(p: Any) -> None:
|
|
1402
|
+
p.add_argument("--source", choices=("project", "eval", "auto"), default="project",
|
|
1403
|
+
help=report_source_help)
|
|
1404
|
+
p.add_argument("--root", type=Path, help="项目根目录 (默认当前工作目录)")
|
|
1405
|
+
p.add_argument("--eval-dir", type=Path, help="审计收据目录 (默认 verification/evals/oss)")
|
|
1406
|
+
p.add_argument("--out", type=Path, help="报告输出目录 (默认与 eval-dir 相同)")
|
|
1407
|
+
p.add_argument("--format", choices=("html", "md", "pdf", "both"), default="both", help="文件格式 (默认 both)")
|
|
1408
|
+
p.add_argument("--title", help="自定义报告主标题")
|
|
1409
|
+
p.add_argument("--json", action="store_true", help="以 JSON 输出报告元数据与生成清单")
|
|
1410
|
+
|
|
1411
|
+
for sub_name in ("formal", "visual", "both"):
|
|
1412
|
+
p = rep_sub.add_parser(sub_name, help=f"生成 {sub_name} 格式安全报告")
|
|
1413
|
+
_add_report_source_args(p)
|
|
1414
|
+
p.set_defaults(handler=command_report)
|
|
1415
|
+
|
|
1416
|
+
serve_parser = rep_sub.add_parser("serve", help="启动双轨报告本地实时 Web 预览服务")
|
|
1417
|
+
serve_parser.add_argument("--host", default="127.0.0.1", help="服务监听地址 (默认 127.0.0.1)")
|
|
1418
|
+
serve_parser.add_argument("--port", type=int, default=8080, help="服务监听端口 (默认 8080)")
|
|
1419
|
+
_add_report_source_args(serve_parser)
|
|
1420
|
+
serve_parser.add_argument("--once", action="store_true", help="单次请求后退出 (测试模式)")
|
|
1421
|
+
serve_parser.set_defaults(handler=command_report)
|
|
1422
|
+
|
|
1423
|
+
_add_report_source_args(rep_parser)
|
|
1424
|
+
rep_parser.set_defaults(handler=command_report)
|
|
1425
|
+
|
|
1426
|
+
completion.set_defaults(
|
|
1427
|
+
completion_commands=tuple(sorted(subparsers.choices)),
|
|
1428
|
+
)
|
|
1429
|
+
|
|
1430
|
+
return parser
|
|
1431
|
+
|
|
1432
|
+
|
|
1433
|
+
# 与引擎只读帮助契约共用一份枚举(定义在 common,CLI 不复制)。
|
|
1434
|
+
_ENGINE_HELP_TOKENS = common.ENGINE_HELP_TOKENS
|
|
1435
|
+
|
|
1436
|
+
|
|
1437
|
+
def _route_engine_help_tokens(tokens: list[str], engine_index: int) -> list[str]:
|
|
1438
|
+
"""把 ``bugx engine`` 之后的首个帮助词改写成引擎自己的 ``help`` 子命令。
|
|
1439
|
+
|
|
1440
|
+
``engine`` 子解析器同时声明了 ``--root`` 与 ``argparse.REMAINDER``,并保留
|
|
1441
|
+
argparse 自动生成的 ``-h/--help``。当帮助词是 ``engine`` 之后的第一个参数时,
|
|
1442
|
+
自动 help 先于 REMAINDER 消费掉它,只打印外层 usage——而 ``bugx engine --help``
|
|
1443
|
+
正是我们在生命周期迁移提示里推荐的入口,引擎帮助(含 ``--dev``)不能丢。
|
|
1444
|
+
引擎对 ``help``/``-h``/``--help`` 三种写法都按只读处理,因此统一折叠成
|
|
1445
|
+
``help``,既保住只读契约,也不依赖 REMAINDER 的边角行为。
|
|
1446
|
+
"""
|
|
1447
|
+
index = engine_index + 1
|
|
1448
|
+
while index < len(tokens):
|
|
1449
|
+
token = tokens[index]
|
|
1450
|
+
if token == "--root":
|
|
1451
|
+
index += 2
|
|
1452
|
+
elif token.startswith("--root="):
|
|
1453
|
+
index += 1
|
|
1454
|
+
else:
|
|
1455
|
+
break
|
|
1456
|
+
if index >= len(tokens) or tokens[index] not in _ENGINE_HELP_TOKENS:
|
|
1457
|
+
return tokens
|
|
1458
|
+
rewritten = list(tokens)
|
|
1459
|
+
rewritten[index] = "help"
|
|
1460
|
+
return rewritten
|
|
1461
|
+
|
|
1462
|
+
|
|
1463
|
+
def main(argv: list[str] | None = None) -> int:
|
|
1464
|
+
from . import common as _common_ns
|
|
1465
|
+
_common_ns._ACTIVE_TRACE_ID = None # placeholder replaced below
|
|
1466
|
+
|
|
1467
|
+
raw_tokens = list(sys.argv[1:] if argv is None else argv)
|
|
1468
|
+
first_cmd = None
|
|
1469
|
+
first_cmd_index = 0
|
|
1470
|
+
for index, token in enumerate(raw_tokens):
|
|
1471
|
+
if token.startswith("-"):
|
|
1472
|
+
continue
|
|
1473
|
+
first_cmd = token
|
|
1474
|
+
first_cmd_index = index
|
|
1475
|
+
break
|
|
1476
|
+
|
|
1477
|
+
if first_cmd:
|
|
1478
|
+
lifecycle_map = {
|
|
1479
|
+
"pre": "bugx engine --root <项目路径> pre",
|
|
1480
|
+
"status": "bugx engine --root <项目路径> status",
|
|
1481
|
+
"workers": "bugx engine --root <项目路径> workers",
|
|
1482
|
+
"heartbeat": "bugx engine --root <项目路径> heartbeat",
|
|
1483
|
+
"post": "bugx engine --root <项目路径> post",
|
|
1484
|
+
"polling": "bugx engine --root <项目路径> polling",
|
|
1485
|
+
"pause": "bugx engine --root <项目路径> pause",
|
|
1486
|
+
"resume": "bugx engine --root <项目路径> resume",
|
|
1487
|
+
"abort": "bugx engine --root <项目路径> abort",
|
|
1488
|
+
"bootstrap-coverage": "bugx engine --root <项目路径> bootstrap-coverage --confirm",
|
|
1489
|
+
}
|
|
1490
|
+
if first_cmd in lifecycle_map:
|
|
1491
|
+
print(
|
|
1492
|
+
f"[bugx] ✗ 命令 '{first_cmd}' 是生命周期引擎子命令,不再作为顶层命令。\n"
|
|
1493
|
+
f" 生命周期控制已统一由全局引擎调度:\n"
|
|
1494
|
+
f" - 执行子命令: {lifecycle_map[first_cmd]}\n"
|
|
1495
|
+
f" - 或启动无人值守挖掘: bugx autonomous\n"
|
|
1496
|
+
f" 查看引擎支持的完整生命周期子命令: bugx engine --help",
|
|
1497
|
+
file=sys.stderr,
|
|
1498
|
+
)
|
|
1499
|
+
return 2
|
|
1500
|
+
|
|
1501
|
+
removed_map = {
|
|
1502
|
+
"matrix": "项目级攻防渗透审计已统一收敛至: bugx audit",
|
|
1503
|
+
"console": "启动统一 Web 控制台与报告预览请使用: bugx report serve",
|
|
1504
|
+
"watch": "实时流式监视日志与 MCP 工具调用请使用: bugx log --watch",
|
|
1505
|
+
"test": "单元测试与提交门禁已从当前发行版移除",
|
|
1506
|
+
}
|
|
1507
|
+
if first_cmd in removed_map:
|
|
1508
|
+
print(
|
|
1509
|
+
f"[bugx] ✗ 命令 '{first_cmd}' 已废弃清理或收敛。\n"
|
|
1510
|
+
f" 推荐用法: {removed_map[first_cmd]}\n"
|
|
1511
|
+
f" 查看所有可用命令: bugx --help",
|
|
1512
|
+
file=sys.stderr,
|
|
1513
|
+
)
|
|
1514
|
+
return 2
|
|
1515
|
+
|
|
1516
|
+
parser = build_parser()
|
|
1517
|
+
parse_tokens = argv
|
|
1518
|
+
if first_cmd == "engine":
|
|
1519
|
+
routed = _route_engine_help_tokens(raw_tokens, first_cmd_index)
|
|
1520
|
+
if routed is not raw_tokens:
|
|
1521
|
+
parse_tokens = routed
|
|
1522
|
+
args = parser.parse_args(parse_tokens)
|
|
1523
|
+
setattr(args, "_console_entrypoint", argv is None)
|
|
1524
|
+
if args.command is None:
|
|
1525
|
+
parser.print_help()
|
|
1526
|
+
return 0
|
|
1527
|
+
if args.command == "help":
|
|
1528
|
+
return command_help(parser, args)
|
|
1529
|
+
root = Path(getattr(args, "root", None) or Path.cwd()).resolve()
|
|
1530
|
+
defer_logging = _defer_command_logging_until_authorized(args)
|
|
1531
|
+
logger = None if defer_logging else _configure_logging(
|
|
1532
|
+
root, getattr(args, "command", "unknown"), args.log_level,
|
|
1533
|
+
)
|
|
1534
|
+
if logger is not None:
|
|
1535
|
+
logging_module = _logging_module(root)
|
|
1536
|
+
_ACTIVE_TRACE_ID = str(logging_module.get_context(logger)["trace_id"])
|
|
1537
|
+
# 0.6.109:同步写 common 命名空间副本——模块 __setattr__ 桥不拦截
|
|
1538
|
+
# STORE_GLOBAL,拆分后 common._run_script 读不到 cli 侧副本
|
|
1539
|
+
# (DOC-034 复审 P1-1:trace 链路断裂)。
|
|
1540
|
+
common._ACTIVE_TRACE_ID = _ACTIVE_TRACE_ID
|
|
1541
|
+
logging_module.log_event(logger, "command_started", command=args.command, root=str(root))
|
|
1542
|
+
else:
|
|
1543
|
+
_ACTIVE_TRACE_ID = None
|
|
1544
|
+
try:
|
|
1545
|
+
read_only_version_check = (
|
|
1546
|
+
args.command == "update" and getattr(args, "check", False)
|
|
1547
|
+
)
|
|
1548
|
+
installation_only_diagnosis = (
|
|
1549
|
+
args.command == "doctor" and getattr(args, "installation_only", False)
|
|
1550
|
+
)
|
|
1551
|
+
if (args.command != "completion" and not read_only_version_check
|
|
1552
|
+
and not installation_only_diagnosis):
|
|
1553
|
+
# Centralize the installation-resource gate so command handlers
|
|
1554
|
+
# cannot swallow a missing asset error and accidentally skip the
|
|
1555
|
+
# one-shot CLI recovery path.
|
|
1556
|
+
# Installation-only doctor is the diagnostic escape hatch: it
|
|
1557
|
+
# reports broken assets itself and must remain runnable when the
|
|
1558
|
+
# central resource gate cannot import the engine.
|
|
1559
|
+
_ensure_core_importable()
|
|
1560
|
+
if args.command == "probe":
|
|
1561
|
+
probe_args = getattr(args, "probe_args", [])
|
|
1562
|
+
result = int(command_probe(args, probe_args))
|
|
1563
|
+
elif args.command == "audit":
|
|
1564
|
+
result = int(command_audit(args))
|
|
1565
|
+
else:
|
|
1566
|
+
result = int(args.handler(args))
|
|
1567
|
+
# reset may have moved the active diagnostic log into its archive;
|
|
1568
|
+
# do not append a completion event through the closed old handler.
|
|
1569
|
+
if logger is not None and args.command != "reset":
|
|
1570
|
+
logging_module.log_event(logger, "command_finished", command=args.command,
|
|
1571
|
+
exit_code=result)
|
|
1572
|
+
return result
|
|
1573
|
+
except MissingAgentAssetError as exc:
|
|
1574
|
+
if (argv is None and exc.repairable and not read_only_version_check
|
|
1575
|
+
and os.environ.get(_ASSET_REPAIR_ATTEMPT_ENV) != "1"):
|
|
1576
|
+
try:
|
|
1577
|
+
detail = repair_cli_agent_assets(channel="stable", root=root)
|
|
1578
|
+
print(f"[bugx] {detail};正在重启原命令以加载新安装...", file=sys.stderr)
|
|
1579
|
+
restart_cli_after_asset_repair()
|
|
1580
|
+
except Exception as repair_exc: # noqa: BLE001
|
|
1581
|
+
if logger is not None and args.command != "reset":
|
|
1582
|
+
logging_module.log_event(
|
|
1583
|
+
logger, "asset_repair_failed", str(repair_exc), level=40,
|
|
1584
|
+
command=args.command, failure_kind=type(repair_exc).__name__,
|
|
1585
|
+
)
|
|
1586
|
+
print(f"[bugx] ✗ {exc}", file=sys.stderr)
|
|
1587
|
+
print(f"[bugx] ✗ 安全自愈未完成:{repair_exc}", file=sys.stderr)
|
|
1588
|
+
print(
|
|
1589
|
+
" 可在发布服务恢复后重试,或先安装经过校验的 bugx-cli wheel。",
|
|
1590
|
+
file=sys.stderr,
|
|
1591
|
+
)
|
|
1592
|
+
return 2
|
|
1593
|
+
|
|
1594
|
+
if logger is not None and args.command != "reset":
|
|
1595
|
+
logging_module.log_event(logger, "command_failed", str(exc),
|
|
1596
|
+
level=40, command=args.command,
|
|
1597
|
+
failure_kind="agent_assets_missing")
|
|
1598
|
+
print(f"[bugx] ✗ {exc}", file=sys.stderr)
|
|
1599
|
+
advice = _generate_ai_exception_advice(exc, getattr(args, "command", None))
|
|
1600
|
+
if advice:
|
|
1601
|
+
print(f" 💡 AI 解决建议: {advice}", file=sys.stderr)
|
|
1602
|
+
return 2
|
|
1603
|
+
except CliError as exc:
|
|
1604
|
+
from .infra.ai_advisor import RuntimeSelfHealInterceptor
|
|
1605
|
+
interceptor = RuntimeSelfHealInterceptor(root)
|
|
1606
|
+
if interceptor.can_heal(exc, command=args.command):
|
|
1607
|
+
print(f"[bugx] ⚠️ 检测到命令 '{args.command}' 执行中断: {exc}", file=sys.stderr)
|
|
1608
|
+
heal_ok, heal_detail = interceptor.try_heal(exc, command=args.command)
|
|
1609
|
+
if heal_ok:
|
|
1610
|
+
print(f" ✨ [AI 动态自愈] {heal_detail},正在原位恢复执行...", file=sys.stderr)
|
|
1611
|
+
try:
|
|
1612
|
+
if args.command == "probe":
|
|
1613
|
+
result = int(command_probe(args, getattr(args, "probe_args", [])))
|
|
1614
|
+
elif args.command == "audit":
|
|
1615
|
+
result = int(command_audit(args))
|
|
1616
|
+
else:
|
|
1617
|
+
result = int(args.handler(args))
|
|
1618
|
+
if logger is not None and args.command != "reset":
|
|
1619
|
+
logging_module.log_event(logger, "command_recovered_and_finished",
|
|
1620
|
+
command=args.command, exit_code=result)
|
|
1621
|
+
print(f" ✓ 命令 '{args.command}' 自愈后成功恢复并完成!", file=sys.stderr)
|
|
1622
|
+
return result
|
|
1623
|
+
except Exception as retry_exc:
|
|
1624
|
+
print(f" ✗ 自愈后重试仍失败 (反自旋终止): {retry_exc}", file=sys.stderr)
|
|
1625
|
+
return 2
|
|
1626
|
+
|
|
1627
|
+
if logger is not None and args.command != "reset":
|
|
1628
|
+
logging_module.log_event(logger, "command_failed", str(exc),
|
|
1629
|
+
level=40, command=args.command)
|
|
1630
|
+
print(f"[bugx] ✗ {exc}", file=sys.stderr)
|
|
1631
|
+
advice = _generate_ai_exception_advice(exc, getattr(args, "command", None))
|
|
1632
|
+
if advice:
|
|
1633
|
+
print(f" 💡 AI 解决建议: {advice}", file=sys.stderr)
|
|
1634
|
+
return 2
|
|
1635
|
+
except Exception as exc: # pragma: no cover - exercised by integration failures.
|
|
1636
|
+
if logger is not None and args.command != "reset":
|
|
1637
|
+
logging_module.log_event(
|
|
1638
|
+
logger, "command_crashed", str(exc), level=40,
|
|
1639
|
+
command=args.command, exception_type=type(exc).__name__,
|
|
1640
|
+
exc_info=True,
|
|
1641
|
+
)
|
|
1642
|
+
err = f"[bugx] ✗ 未处理异常: {type(exc).__name__}: {exc}"
|
|
1643
|
+
try:
|
|
1644
|
+
import core.i18n as i18n
|
|
1645
|
+
err = i18n.exception_text("cli.unhandled", fallback=err, exc_type=type(exc).__name__, exc=exc)
|
|
1646
|
+
except Exception:
|
|
1647
|
+
pass
|
|
1648
|
+
print(err, file=sys.stderr)
|
|
1649
|
+
advice = _generate_ai_exception_advice(exc, getattr(args, "command", None))
|
|
1650
|
+
if advice:
|
|
1651
|
+
print(f" 💡 AI 解决建议: {advice}", file=sys.stderr)
|
|
1652
|
+
return 1
|
|
1653
|
+
finally:
|
|
1654
|
+
# Release the diagnostic log and its lock file once the command
|
|
1655
|
+
# finishes. Windows refuses to delete a file with an open handle, so
|
|
1656
|
+
# leaving the handler attached breaks callers that clean the project
|
|
1657
|
+
# directory in-process (tests, embedded usage). POSIX is unaffected;
|
|
1658
|
+
# a later configure() simply attaches a fresh handler.
|
|
1659
|
+
if logger is not None:
|
|
1660
|
+
for handler in list(logger.handlers):
|
|
1661
|
+
try:
|
|
1662
|
+
handler.close()
|
|
1663
|
+
finally:
|
|
1664
|
+
logger.removeHandler(handler)
|
|
1665
|
+
|
|
1666
|
+
|
|
1667
|
+
if __name__ == "__main__":
|
|
1668
|
+
raise SystemExit(main())
|
|
1669
|
+
|
|
1670
|
+
_SUBMODULES = (
|
|
1671
|
+
common, plugin, lifecycle, agent, doctor, knowledge, cloud, system,
|
|
1672
|
+
stats, project, patch, skill, daemon, autonomous, goal, advisory, report,
|
|
1673
|
+
)
|
|
1674
|
+
|
|
1675
|
+
|
|
1676
|
+
class _CliModule(sys.modules[__name__].__class__):
|
|
1677
|
+
def __setattr__(self, name: str, value: Any) -> None:
|
|
1678
|
+
super().__setattr__(name, value)
|
|
1679
|
+
if not name.startswith("__"):
|
|
1680
|
+
for mod in _SUBMODULES:
|
|
1681
|
+
if hasattr(mod, name):
|
|
1682
|
+
setattr(mod, name, value)
|
|
1683
|
+
|
|
1684
|
+
|
|
1685
|
+
sys.modules[__name__].__class__ = _CliModule
|