bugx-cli 0.1.0 → 0.1.2
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.
- package/README.md +193 -185
- package/core/README.md +2 -2
- package/core/agent/README.md +2 -1
- package/core/agent/agent_artifacts.py +8 -6
- package/core/agent/agent_eval.py +136 -54
- package/core/agent/agent_execution.py +218 -52
- package/core/agent/agent_orchestrator.py +14 -8
- package/core/agent/agent_targets.py +8 -2
- package/core/agent/feature_baseline.py +150 -0
- package/core/assets/README.md +3 -2
- package/core/assets/axe-core/LICENSE-3RD-PARTY.txt +66 -0
- package/core/assets/axe-core/LICENSE.txt +362 -0
- package/core/assets/axe-core/UPSTREAM.md +10 -0
- package/core/assets/axe-core/axe.min.js +12 -0
- package/core/assets/bugx-hero-en.svg +74 -0
- package/core/assets/bugx-hero-zh.svg +74 -0
- package/core/assets/bugx-social-preview.svg +71 -0
- package/core/assets/bugx-wechat-group.png +0 -0
- package/core/assets/codex.png +0 -0
- package/core/assets/dsh.png +0 -0
- package/core/assets/webui-chatgpt.jpg +0 -0
- package/core/assets/webui-session.jpg +0 -0
- package/core/assets/webui-skills.jpg +0 -0
- package/core/assets/webui-studio.jpg +0 -0
- package/core/assets/webui-zcode.jpg +0 -0
- package/core/assets/zcode.png +0 -0
- package/core/audit_packs/README.md +2 -0
- package/core/audit_packs/pitfalls/auth_crypto.json +64 -0
- package/core/audit_packs/pitfalls/file_ssrf_cmd.json +64 -0
- package/core/audit_packs/pitfalls/go_backend.json +66 -0
- package/core/audit_packs/pitfalls/java_spring.json +64 -0
- package/core/audit_packs/pitfalls/js_ts_web.json +67 -0
- package/core/audit_packs/pitfalls/python_web.json +82 -0
- package/core/autonomous_cve/SPEC.md +1 -1
- package/core/autonomous_cve/attack_graph_store.py +152 -106
- package/core/autonomous_cve/behavior_graph.py +8 -2
- package/core/autonomous_cve/verifier.py +4 -1
- package/core/bugx.md +1 -1
- package/core/bugx_paths.py +43 -8
- package/core/cli-help.txt +66 -0
- package/core/cloud_sync/SPEC.md +1 -1
- package/core/cloud_sync/cloud_client.py +81 -11
- package/core/cloud_sync/cloud_onboard.py +42 -1
- package/core/cloud_sync/consent.py +33 -3
- package/core/cloud_sync/flywheel_client.py +186 -15
- package/core/cloud_sync/network_transport.py +24 -3
- package/core/cloud_sync/sensitive_filter.py +2 -2
- package/core/cloud_sync/sync_push.py +12 -10
- package/core/contracts/AGENT_GUIDE.md +6 -9
- package/core/contracts/README.md +2 -2
- package/core/contracts/bugx-runtime-contract.md +1 -1
- package/core/contracts/bugx-worker.md +1 -1
- package/core/contracts/engine_gap_contracts.py +86 -3
- package/core/coverage/coverage_discovery.py +599 -29
- package/core/coverage/coverage_evidence.py +47 -0
- package/core/coverage/coverage_forensics.py +9 -0
- package/core/coverage/coverage_validate.py +6 -1
- package/core/dev_harness/SPEC.md +1 -1
- package/core/engine-integrity.json +670 -442
- package/core/fuzzing/concurrency_fuzzer.py +53 -0
- package/core/fuzzing/differential_oracle.py +562 -27
- package/core/fuzzing/fuzz_input.py +109 -6
- package/core/fuzzing/stateful_fuzzer.py +72 -0
- package/core/governance/secret_redactor.py +22 -10
- package/core/host_acp/SPEC.md +1 -1
- package/core/host_acp/__init__.py +4 -4
- package/core/host_acp/claude.py +59 -1
- package/core/host_acp/cline.py +64 -1
- package/core/host_acp/codex.py +56 -1
- package/core/host_acp/dsh.py +59 -1
- package/core/host_acp/opencode.py +56 -1
- package/core/host_acp/pi.py +59 -1
- package/core/host_acp/zcode.py +59 -1
- package/core/host_runtime/SPEC.md +1 -1
- package/core/host_runtime/adapters.py +1 -1
- package/core/host_runtime/cline.py +13 -0
- package/core/host_runtime/host_evaluators.py +44 -4
- package/core/host_runtime/host_probe.py +1 -1
- package/core/host_runtime/host_provider_arbitrator.py +116 -62
- package/core/host_runtime/host_registry.py +15 -8
- package/core/host_runtime/mcp_registry_gate.py +12 -1
- package/core/host_runtime/pi.py +102 -0
- package/core/host_runtime/provider_facts.py +66 -0
- package/core/hosts/SPEC.md +1 -1
- package/core/hosts/__init__.py +6 -2
- package/core/hosts/_dsh_usage.py +1 -1
- package/core/hosts/base.py +32 -4
- package/core/hosts/claude.py +55 -0
- package/core/hosts/cline.py +6 -2
- package/core/hosts/codex.py +58 -0
- package/core/hosts/dsh.py +9 -1
- package/core/hosts/opencode.py +6 -6
- package/core/hosts/pi.py +159 -2
- package/core/infra/README.md +4 -2
- package/core/infra/__init__.py +2 -0
- package/core/infra/build_info.py +22 -3
- package/core/infra/client_metadata.py +1 -1
- package/core/infra/json_utils.py +22 -0
- package/core/launch_phases/README.md +6 -3
- package/core/launch_phases/SPEC.md +1 -1
- package/core/launch_phases/common.py +21 -2
- package/core/launch_phases/finding_confirm_phase.py +170 -5
- package/core/launch_phases/finding_settlement.py +188 -1
- package/core/launch_phases/judge_phase.py +69 -12
- package/core/launch_phases/orchestrator_controls.py +11 -7
- package/core/launch_phases/post_coverage_sync.py +9 -2
- package/core/launch_phases/post_phase.py +144 -8
- package/core/launch_phases/post_receipt.py +12 -1
- package/core/launch_phases/pre_phase.py +3 -3
- package/core/launch_phases/pre_recon_scout.py +66 -36
- package/core/launch_phases/pre_state_builder.py +23 -176
- package/core/launch_phases/report_sharing.py +3 -7
- package/core/launch_phases/round_orchestrator.py +129 -58
- package/core/launch_phases/semantic_recon.py +545 -0
- package/core/launch_phases/session_runtime.py +56 -9
- package/core/launch_phases/startup_gates.py +36 -8
- package/core/launch_phases/startup_interaction.py +68 -12
- package/core/launch_phases/startup_version_gate.py +13 -3
- package/core/launch_phases/supervisor_bridge.py +46 -17
- package/core/launch_phases/supervisor_coverage.py +8 -2
- package/core/launch_phases/supervisor_degraded.py +1 -9
- package/core/launch_phases/verify_loop.py +767 -0
- package/core/launch_phases/worker_barriers.py +15 -5
- package/core/launch_phases/worker_orchestrator.py +105 -25
- package/core/launch_phases/worker_prior.py +115 -0
- package/core/ledger/README.md +2 -1
- package/core/ledger/SPEC.md +1 -1
- package/core/ledger/_facade.py +2 -1
- package/core/ledger/archive_ops.py +60 -2
- package/core/ledger/cli.py +6 -1
- package/core/ledger/export_ops.py +6 -1
- package/core/ledger/finding_confirmation.py +48 -6
- package/core/ledger/finding_lifecycle.py +428 -5
- package/core/ledger/finding_verification.py +555 -10
- package/core/ledger/fp_ledger.py +255 -0
- package/core/ledger/incidents.py +10 -4
- package/core/ledger/patterns.py +10 -7
- package/core/ledger/receipt_contract.py +17 -1
- package/core/ledger/sync_ops.py +21 -16
- package/core/ledger/tool_experience.py +2 -1
- package/core/ledger/verify_life.py +88 -17
- package/core/locales/en-US.json +2 -2
- package/core/locales/zh-CN.json +2 -2
- package/core/mcp_handlers/SPEC.md +1 -1
- package/core/mcp_handlers/base.py +23 -3
- package/core/mcp_handlers/channel_lifecycle.py +85 -30
- package/core/mcp_handlers/retrieval_handlers.py +11 -1
- package/core/mcp_handlers/rpc_server.py +6 -1
- package/core/mcp_handlers/supervisor_handlers.py +32 -6
- package/core/mcp_handlers/tool_table.py +15 -0
- package/core/mcp_runtime_support/environment.py +0 -38
- package/core/mcp_runtime_support/verifier.py +0 -52
- package/core/metadata.txt +2 -3
- package/core/planning/README.md +2 -1
- package/core/planning/domain_router.py +4 -2
- package/core/planning/dynamic_flow_analyzer.py +219 -14
- package/core/planning/judge_pipeline.py +87 -4
- package/core/planning/prompt_harness.py +57 -15
- package/core/planning/prompt_policy_engine.py +386 -0
- package/core/planning/spec_harvester.py +4 -4
- package/core/probes/INTERFACE.md +11 -1
- package/core/probes/SPEC.md +11 -1
- package/core/probes/__init__.py +46 -40
- package/core/probes/android_probe.py +177 -9
- package/core/probes/codebase_memory_probe.py +57 -0
- package/core/probes/desktop_probe.py +104 -0
- package/core/probes/differential_probe.py +99 -21
- package/core/probes/efficiency_probe.py +64 -0
- package/core/probes/ios_binary_probe.py +105 -1
- package/core/probes/memory_probe.py +66 -0
- package/core/probes/miniprogram_probe.py +75 -13
- package/core/probes/mobile_probe.py +215 -30
- package/core/probes/native_probe.py +88 -0
- package/core/probes/openwiki_probe.py +70 -0
- package/core/probes/pattern_probe.py +106 -0
- package/core/probes/platform_probe.py +81 -0
- package/core/probes/probe_registry.py +108 -7
- package/core/probes/sast_fixture_corpus.py +340 -0
- package/core/probes/sast_probe.py +553 -52
- package/core/probes/sast_rules.py +668 -28
- package/core/probes/sca_scanner.py +48 -0
- package/core/probes/ui_accessibility.py +149 -0
- package/core/probes/ui_audit.py +513 -0
- package/core/probes/ui_contract.py +273 -0
- package/core/probes/ui_evidence.py +212 -0
- package/core/probes/ui_measurements.py +314 -0
- package/core/probes/ui_repair.py +250 -0
- package/core/probes/ui_review.py +133 -0
- package/core/probes/ui_storybook.py +107 -0
- package/core/probes/ui_tokens.py +185 -0
- package/core/probes/ui_visual_diff.py +131 -0
- package/core/probes/web_probe.py +373 -18
- package/core/project_profiler/SPEC.md +1 -1
- package/core/project_profiler/arbitrator.py +6 -1
- package/core/project_profiler/detector.py +8 -1
- package/core/project_profiler/strategy.py +51 -15
- package/core/prompts/README.md +4 -2
- package/core/prompts/command_routing_en.md +2 -2
- package/core/prompts/command_routing_zh.md +2 -2
- package/core/prompts/policies/prompt_policies.json +101 -0
- package/core/prompts/stages/stage_repair.md +1 -1
- package/core/prompts/stages/stage_verify.defensive.md +42 -0
- package/core/prompts/stages/stage_verify.md +44 -0
- package/core/repair/README.md +1 -1
- package/core/repair/l7_repair_loop.py +1 -4
- package/core/repair/rsi_fixer.py +4 -4
- package/core/repair/rsi_loop.py +1 -3
- package/core/repair/rsi_repair.py +7 -7
- package/core/repair/rsi_scope.py +27 -8
- package/core/report_engine/SPEC.md +1 -1
- package/core/report_engine/attestation.py +8 -4
- package/core/report_engine/finding_report.py +2 -1
- package/core/report_engine/models.py +7 -9
- package/core/report_engine/report_share.py +0 -8
- package/core/report_engine/sast_bridge.py +2 -2
- package/core/report_engine/server.py +18 -8
- package/core/report_engine/web-conformance.md +123 -18
- package/core/report_engine/web_conformance.py +21 -52
- package/core/retrieval/README.md +2 -1
- package/core/retrieval/SPEC.md +1 -1
- package/core/retrieval/code_analyzer.py +50 -14
- package/core/retrieval/context_assembler.py +7 -1
- package/core/retrieval/knowledge_sync.py +108 -14
- package/core/retrieval/pitfall_packs.py +277 -0
- package/core/retrieval/symbol_index.py +25 -6
- package/core/retrieval/universal_code_matcher.py +234 -49
- package/core/runtime/README.md +1 -1
- package/core/runtime/bugx_logging.py +78 -7
- package/core/runtime/fixture_solidify.py +5 -10
- package/core/runtime/global_telemetry.py +20 -0
- package/core/runtime/incident_eval.py +1 -1
- package/core/runtime/model_runner.py +4 -41
- package/core/runtime/platform_adapter.py +2 -2
- package/core/runtime/prep_validate.py +4 -2
- package/core/runtime/project_settings.py +2 -1
- package/core/runtime/scenario_eval.py +50 -8
- package/core/skills/bugx_docs_mcp_server.py +3 -1
- package/core/skills/bugx_mcp_server.py +29 -2
- package/core/skills/tools_kb.py +1 -1
- package/core/supervisor/README.md +1 -1
- package/core/supervisor/SPEC.md +1 -1
- package/core/supervisor/budget_governor.py +503 -9
- package/core/supervisor/checkpoint_pipeline.py +248 -6
- package/core/supervisor/checkpoint_sync.py +13 -0
- package/core/supervisor/claim_events.py +1 -1
- package/core/supervisor/finding_workflow.py +22 -5
- package/core/supervisor/lease_manager.py +1 -1
- package/core/supervisor/lifecycle_blocks.py +6 -1
- package/core/supervisor/rejection_remedies.py +52 -5
- package/core/supervisor/serial_authorization.py +48 -4
- package/core/supervisor/task_scheduler.py +2 -2
- package/core/supervisor/worker_checkpoint.py +8 -1
- package/core/supervisor/worker_runtime.py +8 -2
- package/core/supervisor_types/worker_claim.py +9 -0
- package/core/webui/README.md +1 -1
- package/core/webui/SPEC.md +2 -1
- package/core/webui/adapters/claude.py +5 -1
- package/core/webui/adapters/cline.py +10 -2
- package/core/webui/adapters/codex.py +5 -1
- package/core/webui/adapters/dsh.py +5 -1
- package/core/webui/docs_session_service.py +2 -2
- package/core/webui/mcp_inspector.py +11 -7
- package/core/webui/static/00-base.css +1060 -0
- package/core/webui/static/01-monitoring.css +802 -0
- package/core/webui/static/02-header-actions.css +321 -0
- package/core/webui/static/03-trigger-popover.css +697 -0
- package/core/webui/static/04-composer.css +628 -0
- package/core/webui/static/05-skills-center.css +878 -0
- package/core/webui/static/06-mcp-center.css +623 -0
- package/core/webui/static/07-skill-detail.css +265 -0
- package/core/webui/static/08-files-management.css +167 -0
- package/core/webui/static/09-files-center.css +386 -0
- package/core/webui/static/10-icons.css +105 -0
- package/core/webui/static/11-project-options.css +185 -0
- package/core/webui/static/12-profile-tab.css +383 -0
- package/core/webui/static/design-tokens.css +113 -0
- package/core/webui/static/index.html +14 -1
- package/core/webui/workspace_service.py +1 -1
- package/docs/07_distribution/01_README_NPM.md +193 -185
- package/ecosystem/integrations/README.md +1 -1
- package/ecosystem/integrations/dsh/mcp/package.json +1 -1
- package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +1 -1
- package/ecosystem/integrations/dsh/ui/package.json +1 -1
- package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +4 -4
- package/ecosystem/integrations/opencode/mcp-lock.json +14 -6
- package/ecosystem/integrations/opencode/opencode.json +23 -12
- package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
- package/ecosystem/integrations/qoder/connector-meta.json +1 -1
- package/ecosystem/integrations/workbuddy/connector-meta.json +1 -1
- package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +1 -1
- package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +1 -1
- package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +1 -1
- package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +2 -2
- package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +1 -1
- package/interfaces/bin/bugx.js +37 -0
- package/interfaces/cli/bugx_cli/__init__.py +4 -2
- package/interfaces/cli/bugx_cli/cli.py +172 -69
- package/interfaces/cli/bugx_cli/commands/advisory.py +1 -1
- package/interfaces/cli/bugx_cli/commands/agent.py +461 -134
- package/interfaces/cli/bugx_cli/commands/audit.py +10 -9
- package/interfaces/cli/bugx_cli/commands/autonomous.py +1 -1
- package/interfaces/cli/bugx_cli/commands/cloud.py +31 -22
- package/interfaces/cli/bugx_cli/commands/doctor.py +449 -204
- package/interfaces/cli/bugx_cli/commands/interaction.py +5 -1
- package/interfaces/cli/bugx_cli/commands/knowledge.py +5 -4
- package/interfaces/cli/bugx_cli/commands/lifecycle.py +3 -3
- package/interfaces/cli/bugx_cli/commands/plugin.py +58 -23
- package/interfaces/cli/bugx_cli/commands/plugin_claude.py +7 -7
- package/interfaces/cli/bugx_cli/commands/plugin_funide.py +2 -1
- package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +1 -1
- package/interfaces/cli/bugx_cli/commands/project.py +6 -13
- package/interfaces/cli/bugx_cli/commands/report.py +2 -6
- package/interfaces/cli/bugx_cli/commands/system.py +524 -169
- package/interfaces/cli/bugx_cli/common.py +21 -15
- package/interfaces/cli/bugx_cli/host_adapters.py +29 -54
- package/interfaces/cli/bugx_cli/hosts/registry.py +8 -6
- package/interfaces/cli/bugx_cli/infra/ai_advisor.py +157 -27
- package/interfaces/cli/bugx_cli/infra/engine_installer.py +35 -16
- package/interfaces/cli/bugx_cli/infra/host_sync.py +11 -8
- package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +76 -5
- package/interfaces/cli/bugx_cli/infra/security.py +13 -6
- package/package.json +30 -15
- package/pyproject.toml +60 -9
- package/scripts/ensure-python.mjs +7 -7
- package/scripts/sync-version.mjs +10 -21
- package/scripts/test-npm-wrapper.mjs +1 -1
- package/core/assets/bugx-hero-cn.png +0 -0
- package/core/assets/bugx-hero-en.png +0 -0
- package/core/webui/static/project-settings.css +0 -6458
- package/docs/07_distribution/README.md +0 -16
- package/docs/README.md +0 -121
- package/interfaces/README.md +0 -143
- package/interfaces/bin/README.md +0 -35
- package/interfaces/cli/README.md +0 -90
- package/scripts/README.md +0 -118
|
@@ -47,6 +47,13 @@ class _CloudSyncExplicitAction(argparse.Action):
|
|
|
47
47
|
setattr(namespace, self.dest, values)
|
|
48
48
|
setattr(namespace, "cloud_sync_explicit", True)
|
|
49
49
|
|
|
50
|
+
|
|
51
|
+
class _UniqueRootAction(argparse.Action):
|
|
52
|
+
def __call__(self, parser, namespace, values, option_string=None):
|
|
53
|
+
if getattr(namespace, self.dest, None) is not None:
|
|
54
|
+
parser.error("重复指定 --root,请保留一个项目路径。")
|
|
55
|
+
setattr(namespace, self.dest, values)
|
|
56
|
+
|
|
50
57
|
# 将各领域子模块的符号(含公共工具与测试挂载点)全量导出到顶层 cli 命名空间
|
|
51
58
|
for _mod in (
|
|
52
59
|
common, plugin, lifecycle, agent, doctor, knowledge, cloud, system, stats,
|
|
@@ -117,12 +124,71 @@ _INTENT_SYNONYMS: dict[str, str] = {
|
|
|
117
124
|
class _BugXArgumentParser(argparse.ArgumentParser):
|
|
118
125
|
"""带 AI 意图理解与智能模糊纠错的增强参数解析器。"""
|
|
119
126
|
|
|
127
|
+
def __init__(self, *args, **kwargs):
|
|
128
|
+
kwargs.setdefault("allow_abbrev", False)
|
|
129
|
+
super().__init__(*args, **kwargs)
|
|
130
|
+
|
|
131
|
+
@staticmethod
|
|
132
|
+
def _is_switch(action: argparse.Action | None) -> bool:
|
|
133
|
+
return isinstance(action, (
|
|
134
|
+
argparse._StoreTrueAction, argparse._StoreFalseAction,
|
|
135
|
+
argparse.BooleanOptionalAction,
|
|
136
|
+
))
|
|
137
|
+
|
|
138
|
+
def _switch_error(self, option: str, value: str, action: argparse.Action) -> typing.NoReturn:
|
|
139
|
+
negative = isinstance(action, argparse._StoreFalseAction) or (
|
|
140
|
+
isinstance(action, argparse.BooleanOptionalAction) and option.startswith("--no-")
|
|
141
|
+
)
|
|
142
|
+
if (value.casefold() == "true") != negative:
|
|
143
|
+
guidance = f"直接使用 {option}。"
|
|
144
|
+
elif isinstance(action, argparse.BooleanOptionalAction):
|
|
145
|
+
opposite = option.removeprefix("--no-") if negative else option.removeprefix("--")
|
|
146
|
+
prefix = "--" if negative else "--no-"
|
|
147
|
+
guidance = f"改用 {prefix}{opposite}。"
|
|
148
|
+
else:
|
|
149
|
+
guidance = f"省略 {option},使用命令默认值。"
|
|
150
|
+
super().error(f"布尔开关 {option} 不接受值。{guidance}")
|
|
151
|
+
|
|
152
|
+
def parse_args(self, args=None, namespace=None):
|
|
153
|
+
parsed, extras = self.parse_known_args(args, namespace)
|
|
154
|
+
current = self
|
|
155
|
+
active_options = dict(current._option_string_actions)
|
|
156
|
+
while True:
|
|
157
|
+
group = next((a for a in current._actions if isinstance(a, argparse._SubParsersAction)), None)
|
|
158
|
+
if group is None:
|
|
159
|
+
break
|
|
160
|
+
child = group.choices.get(getattr(parsed, group.dest, None))
|
|
161
|
+
if child is None:
|
|
162
|
+
break
|
|
163
|
+
current = child
|
|
164
|
+
active_options.update(current._option_string_actions)
|
|
165
|
+
for token in extras:
|
|
166
|
+
match = re.fullmatch(r"([A-Za-z][\w-]*)=(true|false)", token, re.IGNORECASE)
|
|
167
|
+
if match:
|
|
168
|
+
option = "--" + match[1]
|
|
169
|
+
action = active_options.get(option)
|
|
170
|
+
if self._is_switch(action):
|
|
171
|
+
self._switch_error(option, match[2], action)
|
|
172
|
+
if extras:
|
|
173
|
+
self.error("unrecognized arguments: " + " ".join(extras))
|
|
174
|
+
parent_root = vars(parsed).pop("_parent_root", None)
|
|
175
|
+
if parent_root is not None:
|
|
176
|
+
if getattr(parsed, "root", None) is not None:
|
|
177
|
+
self.error("重复指定 --root,请保留一个项目路径。")
|
|
178
|
+
parsed.root = parent_root
|
|
179
|
+
elif getattr(parsed, "command", None) in {"project", "report"} and not hasattr(parsed, "root"):
|
|
180
|
+
parsed.root = Path.cwd() if parsed.command == "project" else None
|
|
181
|
+
return parsed
|
|
182
|
+
|
|
120
183
|
def error(self, message: str) -> typing.NoReturn:
|
|
121
184
|
match = re.search(r"argument command: invalid choice: '([^']+)'", message)
|
|
122
185
|
if match:
|
|
123
186
|
bad_cmd = match.group(1).strip()
|
|
124
187
|
from .infra.ai_advisor import CommandIntentArbitrator
|
|
125
|
-
|
|
188
|
+
# 命令面真值来自解析器自身的 choose-from 清单——建议永不指向不存在的命令。
|
|
189
|
+
choices_match = re.search(r"choose from (.+?)\)", message)
|
|
190
|
+
known = re.findall(r"'([^']+)'", choices_match.group(1)) if choices_match else None
|
|
191
|
+
arbitrator = CommandIntentArbitrator(known_commands=known)
|
|
126
192
|
res = arbitrator.infer_intent(bad_cmd)
|
|
127
193
|
|
|
128
194
|
err_output = [
|
|
@@ -140,6 +206,17 @@ class _BugXArgumentParser(argparse.ArgumentParser):
|
|
|
140
206
|
print("\n".join(err_output), file=sys.stderr)
|
|
141
207
|
sys.exit(2)
|
|
142
208
|
|
|
209
|
+
explicit_bool = re.fullmatch(
|
|
210
|
+
r"argument (\S+): ignored explicit argument ['\"](true|false)['\"]",
|
|
211
|
+
message,
|
|
212
|
+
flags=re.IGNORECASE,
|
|
213
|
+
)
|
|
214
|
+
if explicit_bool:
|
|
215
|
+
option = explicit_bool[1].split("/", 1)[0]
|
|
216
|
+
action = self._option_string_actions.get(option)
|
|
217
|
+
if self._is_switch(action):
|
|
218
|
+
self._switch_error(option, explicit_bool[2], action)
|
|
219
|
+
|
|
143
220
|
match_arg = re.search(r"unrecognized arguments:\s*(.+)", message)
|
|
144
221
|
if match_arg:
|
|
145
222
|
bad_args = match_arg.group(1).strip()
|
|
@@ -302,6 +379,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
302
379
|
reset.add_argument("--force", action="store_true", help="强制重置(忽略活跃状态检查;执行前依然创建外部备份)")
|
|
303
380
|
reset.add_argument(
|
|
304
381
|
"--no-backup", "--skip-backup", action="store_true", dest="no_backup",
|
|
382
|
+
default=argparse.SUPPRESS,
|
|
305
383
|
help="跳过执行前自动创建的外部备份归档",
|
|
306
384
|
)
|
|
307
385
|
reset.add_argument("--json", action="store_true")
|
|
@@ -334,6 +412,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
334
412
|
uninstall.add_argument("--yes", action="store_true", help="确认不可逆数据清理")
|
|
335
413
|
uninstall.add_argument(
|
|
336
414
|
"--no-backup", "--skip-backup", action="store_true", dest="no_backup",
|
|
415
|
+
default=argparse.SUPPRESS,
|
|
337
416
|
help="跳过执行前自动创建的外部备份归档",
|
|
338
417
|
)
|
|
339
418
|
uninstall.add_argument("--json", action="store_true")
|
|
@@ -653,6 +732,10 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
653
732
|
knowledge.add_argument("--output", type=Path)
|
|
654
733
|
knowledge.add_argument("--bundle-id")
|
|
655
734
|
knowledge.add_argument("--contributor", default="local-supervisor")
|
|
735
|
+
knowledge.add_argument(
|
|
736
|
+
"--include-source-snippets", action="store_true",
|
|
737
|
+
help="导出时在便携包中携带 before/after 源码片段(默认不带;开启后经片段级审查)",
|
|
738
|
+
)
|
|
656
739
|
knowledge.add_argument("--reviewer")
|
|
657
740
|
knowledge.add_argument("--reason")
|
|
658
741
|
knowledge.set_defaults(handler=command_knowledge)
|
|
@@ -685,7 +768,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
685
768
|
"engine", help="从全局引擎运行生命周期命令(项目不再提供 .bugx/core 入口)",
|
|
686
769
|
)
|
|
687
770
|
engine.add_argument(
|
|
688
|
-
"--root", type=Path, default=None,
|
|
771
|
+
"--root", type=Path, default=None, action=_UniqueRootAction,
|
|
689
772
|
help="项目根目录;缺省时依次读 BUGX_PROJECT_ROOT / 宿主工作区环境变量,最后才用 cwd",
|
|
690
773
|
)
|
|
691
774
|
engine.add_argument(
|
|
@@ -780,7 +863,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
780
863
|
"sync", help="立即执行云端同步;未登录时自动打开授权页",
|
|
781
864
|
))
|
|
782
865
|
p_sync.add_argument("--scope", dest="sync_scope", choices=("project", "global", "all"), default=None,
|
|
783
|
-
help="
|
|
866
|
+
help="同步范围;省略时读云端配置,未配置时仅同步当前项目")
|
|
784
867
|
p_sync.add_argument("--detail-mode", choices=("full", "summary"), default=None,
|
|
785
868
|
help="私有同步详情粒度;缺省读 cloud-config.json sync_detail_mode(默认 full),summary 仅上传摘要/计数/状态")
|
|
786
869
|
p_sync.add_argument("--calibrate", action="store_true",
|
|
@@ -1025,14 +1108,9 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
1025
1108
|
)
|
|
1026
1109
|
sup.add_argument(
|
|
1027
1110
|
"supervisor_command",
|
|
1028
|
-
choices=
|
|
1029
|
-
"install", "status", "rpc",
|
|
1030
|
-
# 带外动作白名单由 commands.system 单一真源派生(恢复 + 数据修复):
|
|
1031
|
-
# 此处不再复制枚举,避免「帮助列出但 dispatch 拒绝」的静默漂移。
|
|
1032
|
-
*system.SUPERVISOR_PASSTHROUGH_ACTIONS,
|
|
1033
|
-
),
|
|
1111
|
+
choices=system.SUPERVISOR_COMMANDS,
|
|
1034
1112
|
)
|
|
1035
|
-
sup.add_argument("--root", type=Path, default=
|
|
1113
|
+
sup.add_argument("--root", type=Path, default=None, action=_UniqueRootAction)
|
|
1036
1114
|
sup.add_argument("supervisor_args", nargs=argparse.REMAINDER, default=[])
|
|
1037
1115
|
sup.set_defaults(handler=command_supervisor)
|
|
1038
1116
|
|
|
@@ -1199,55 +1277,63 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
1199
1277
|
project_sub = project_parser.add_subparsers(dest="project_action")
|
|
1200
1278
|
|
|
1201
1279
|
p_analyze = project_sub.add_parser("analyze", help="全景扫描并分析当前或指定工程的代码体量与画像")
|
|
1202
|
-
p_analyze.add_argument("--root", type=Path, default=
|
|
1203
|
-
|
|
1280
|
+
p_analyze.add_argument("--root", type=Path, default=argparse.SUPPRESS, action=_UniqueRootAction,
|
|
1281
|
+
help="项目根目录(默认当前目录)")
|
|
1282
|
+
p_analyze.add_argument("--json", action="store_true", default=argparse.SUPPRESS, help="以结构化 JSON 输出")
|
|
1204
1283
|
p_analyze.set_defaults(handler=command_project)
|
|
1205
1284
|
|
|
1206
1285
|
p_show = project_sub.add_parser("show", help="查看已缓存的项目画像与度量")
|
|
1207
|
-
p_show.add_argument("--root", type=Path, default=
|
|
1208
|
-
|
|
1286
|
+
p_show.add_argument("--root", type=Path, default=argparse.SUPPRESS, action=_UniqueRootAction,
|
|
1287
|
+
help="项目根目录(默认当前目录)")
|
|
1288
|
+
p_show.add_argument("--json", action="store_true", default=argparse.SUPPRESS, help="以结构化 JSON 输出")
|
|
1209
1289
|
p_show.set_defaults(handler=command_project)
|
|
1210
1290
|
|
|
1211
1291
|
p_sync = project_sub.add_parser("sync", help="将项目画像与代码指标同步至云端看板")
|
|
1212
|
-
p_sync.add_argument("--root", type=Path, default=
|
|
1213
|
-
|
|
1292
|
+
p_sync.add_argument("--root", type=Path, default=argparse.SUPPRESS, action=_UniqueRootAction,
|
|
1293
|
+
help="项目根目录(默认当前目录)")
|
|
1294
|
+
p_sync.add_argument("--json", action="store_true", default=argparse.SUPPRESS, help="以结构化 JSON 输出")
|
|
1214
1295
|
p_sync.set_defaults(handler=command_project)
|
|
1215
1296
|
|
|
1216
1297
|
p_list = project_sub.add_parser("list", help="查看全局所有受管工程列表 (~/.bugx/projects.json)")
|
|
1217
|
-
p_list.add_argument("--root", type=Path, default=
|
|
1218
|
-
|
|
1298
|
+
p_list.add_argument("--root", type=Path, default=argparse.SUPPRESS, action=_UniqueRootAction,
|
|
1299
|
+
help="项目根目录(默认当前目录)")
|
|
1300
|
+
p_list.add_argument("--json", action="store_true", default=argparse.SUPPRESS, help="以结构化 JSON 输出")
|
|
1219
1301
|
p_list.set_defaults(handler=command_project)
|
|
1220
1302
|
|
|
1221
1303
|
p_refresh = project_sub.add_parser("refresh", help="全量扫描并刷新全局受管工程列表 (~/.bugx/projects.json)")
|
|
1222
|
-
p_refresh.add_argument("--root", type=Path, default=
|
|
1223
|
-
|
|
1304
|
+
p_refresh.add_argument("--root", type=Path, default=argparse.SUPPRESS, action=_UniqueRootAction,
|
|
1305
|
+
help="项目根目录(默认当前目录)")
|
|
1306
|
+
p_refresh.add_argument("--json", action="store_true", default=argparse.SUPPRESS, help="以结构化 JSON 输出")
|
|
1224
1307
|
p_refresh.set_defaults(handler=command_project)
|
|
1225
1308
|
|
|
1226
1309
|
p_rebind = project_sub.add_parser(
|
|
1227
1310
|
"rebind",
|
|
1228
1311
|
help="诊断或迁移 .bugx 的项目身份(项目目录搬移/改名后使用)",
|
|
1229
1312
|
)
|
|
1230
|
-
p_rebind.add_argument("--root", type=Path, default=
|
|
1313
|
+
p_rebind.add_argument("--root", type=Path, default=argparse.SUPPRESS, action=_UniqueRootAction,
|
|
1314
|
+
help="项目根目录(默认当前目录)")
|
|
1231
1315
|
p_rebind.add_argument(
|
|
1232
1316
|
"--migrate", action="store_true",
|
|
1233
1317
|
help="把盘上 project_id 重写为当前路径指纹并保留 project_uid(确认是搬移而非误用他人布局)",
|
|
1234
1318
|
)
|
|
1235
|
-
p_rebind.add_argument("--json", action="store_true", help="以结构化 JSON 输出")
|
|
1319
|
+
p_rebind.add_argument("--json", action="store_true", default=argparse.SUPPRESS, help="以结构化 JSON 输出")
|
|
1236
1320
|
p_rebind.set_defaults(handler=command_project)
|
|
1237
1321
|
|
|
1238
1322
|
p_settings = project_sub.add_parser("settings", help="查看或修改项目的门禁配置、挖掘情报、MCP 与 Skill")
|
|
1239
1323
|
p_settings.add_argument("target", nargs="?", default=None, help="目标工程路径或工程 Hash(默认当前工作区)")
|
|
1240
|
-
p_settings.add_argument("--root", type=Path, default=
|
|
1324
|
+
p_settings.add_argument("--root", type=Path, default=argparse.SUPPRESS, action=_UniqueRootAction,
|
|
1325
|
+
help="项目根目录(默认当前目录)")
|
|
1241
1326
|
p_settings.add_argument("--set-cloud-sync", choices=["on", "off"], default=None, help="设置是否开启云端同步")
|
|
1242
1327
|
p_settings.add_argument("--set-review", choices=["auto", "interactive", "off"], default=None, help="设置审查执行模式")
|
|
1243
1328
|
p_settings.add_argument("--set-polling", choices=["auto", "manual", "off"], default=None, help="设置漏洞轮询策略")
|
|
1244
1329
|
p_settings.add_argument("--set-auto-fix", choices=["on", "off", "confirm"], default=None, help="设置是否自动修改代码")
|
|
1245
1330
|
p_settings.add_argument("--set-commit", choices=["round", "task", "off"], default=None, help="设置代码自动提交策略")
|
|
1246
|
-
p_settings.add_argument("--json", action="store_true", help="以结构化 JSON 输出")
|
|
1331
|
+
p_settings.add_argument("--json", action="store_true", default=argparse.SUPPRESS, help="以结构化 JSON 输出")
|
|
1247
1332
|
p_settings.set_defaults(handler=command_project)
|
|
1248
1333
|
|
|
1249
1334
|
project_parser.set_defaults(project_action="analyze", handler=command_project)
|
|
1250
|
-
project_parser.add_argument("--root",
|
|
1335
|
+
project_parser.add_argument("--root", dest="_parent_root", metavar="ROOT", type=Path,
|
|
1336
|
+
action=_UniqueRootAction, help="项目根目录(默认当前目录)")
|
|
1251
1337
|
project_parser.add_argument("--json", action="store_true", help="以结构化 JSON 输出")
|
|
1252
1338
|
|
|
1253
1339
|
# ── view:安全查看源文件切片与视窗(DOC-225,具越界自愈与沙箱隔离)──
|
|
@@ -1391,34 +1477,35 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
1391
1477
|
"eval=--eval-dir 下的引擎自测收据;auto=优先项目运行态、不可用时退回收据"
|
|
1392
1478
|
)
|
|
1393
1479
|
|
|
1394
|
-
def _add_report_source_args(p: Any) -> None:
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1480
|
+
def _add_report_source_args(p: Any, *, nested: bool = False) -> None:
|
|
1481
|
+
def add(name: str, *, default: Any = None, **kwargs: Any) -> None:
|
|
1482
|
+
p.add_argument(name, default=argparse.SUPPRESS if nested else default, **kwargs)
|
|
1483
|
+
|
|
1484
|
+
add("--source", choices=("project", "eval", "auto"), default="project", help=report_source_help)
|
|
1485
|
+
add("--root", metavar="ROOT", dest="root" if nested else "_parent_root",
|
|
1486
|
+
type=Path, action=_UniqueRootAction, help="项目根目录 (默认当前工作目录)")
|
|
1487
|
+
add("--eval-dir", type=Path, help="审计收据目录 (默认 verification/evals/oss)")
|
|
1488
|
+
add("--out", type=Path, help="报告输出目录 (默认与 eval-dir 相同)")
|
|
1489
|
+
add("--format", choices=("html", "md", "pdf", "both"), default="both", help="文件格式 (默认 both)")
|
|
1490
|
+
add("--title", help="自定义报告主标题")
|
|
1491
|
+
add("--json", action="store_true", default=False, help="以 JSON 输出报告元数据与生成清单")
|
|
1403
1492
|
|
|
1404
1493
|
for sub_name in ("formal", "visual", "both"):
|
|
1405
1494
|
p = rep_sub.add_parser(sub_name, help=f"生成 {sub_name} 格式安全报告")
|
|
1406
|
-
_add_report_source_args(p)
|
|
1495
|
+
_add_report_source_args(p, nested=True)
|
|
1407
1496
|
p.set_defaults(handler=command_report)
|
|
1408
1497
|
|
|
1409
1498
|
serve_parser = rep_sub.add_parser("serve", help="启动双轨报告本地实时 Web 预览服务")
|
|
1410
1499
|
serve_parser.add_argument("--host", default="127.0.0.1", help="服务监听地址 (默认 127.0.0.1)")
|
|
1411
1500
|
serve_parser.add_argument("--port", type=int, default=8080, help="服务监听端口 (默认 8080)")
|
|
1412
|
-
_add_report_source_args(serve_parser)
|
|
1501
|
+
_add_report_source_args(serve_parser, nested=True)
|
|
1413
1502
|
serve_parser.add_argument("--once", action="store_true", help="单次请求后退出 (测试模式)")
|
|
1414
1503
|
serve_parser.set_defaults(handler=command_report)
|
|
1415
1504
|
|
|
1416
1505
|
_add_report_source_args(rep_parser)
|
|
1417
1506
|
rep_parser.set_defaults(handler=command_report)
|
|
1418
1507
|
|
|
1419
|
-
completion.set_defaults(
|
|
1420
|
-
completion_commands=tuple(sorted(subparsers.choices)),
|
|
1421
|
-
)
|
|
1508
|
+
completion.set_defaults(completion_tree=system.completion_tree(parser))
|
|
1422
1509
|
|
|
1423
1510
|
return parser
|
|
1424
1511
|
|
|
@@ -1453,15 +1540,40 @@ def _route_engine_help_tokens(tokens: list[str], engine_index: int) -> list[str]
|
|
|
1453
1540
|
return rewritten
|
|
1454
1541
|
|
|
1455
1542
|
|
|
1543
|
+
def _maybe_report_installation(command: str) -> None:
|
|
1544
|
+
"""Best-effort daily install/heartbeat reporting for normal CLI commands.
|
|
1545
|
+
|
|
1546
|
+
Privacy/configuration commands are intentionally excluded so a user can
|
|
1547
|
+
disable telemetry without the control command itself causing another
|
|
1548
|
+
outbound request. The reporter has its own gate and never propagates a
|
|
1549
|
+
network or local-state error into the requested CLI command.
|
|
1550
|
+
"""
|
|
1551
|
+
if command in {"completion", "config", "cloud", "auth", "telemetry", "update", "stats", "view", "log"}:
|
|
1552
|
+
return
|
|
1553
|
+
try:
|
|
1554
|
+
from core.cloud_sync.flywheel_client import maybe_report_installation
|
|
1555
|
+
|
|
1556
|
+
maybe_report_installation()
|
|
1557
|
+
except Exception:
|
|
1558
|
+
pass
|
|
1559
|
+
|
|
1560
|
+
|
|
1456
1561
|
def main(argv: list[str] | None = None) -> int:
|
|
1457
1562
|
from . import common as _common_ns
|
|
1458
1563
|
_common_ns._ACTIVE_TRACE_ID = None # placeholder replaced below
|
|
1459
1564
|
|
|
1460
1565
|
raw_tokens = list(sys.argv[1:] if argv is None else argv)
|
|
1566
|
+
parser = build_parser()
|
|
1461
1567
|
first_cmd = None
|
|
1462
1568
|
first_cmd_index = 0
|
|
1569
|
+
skip_value = False
|
|
1463
1570
|
for index, token in enumerate(raw_tokens):
|
|
1571
|
+
if skip_value:
|
|
1572
|
+
skip_value = False
|
|
1573
|
+
continue
|
|
1464
1574
|
if token.startswith("-"):
|
|
1575
|
+
action = parser._option_string_actions.get(token)
|
|
1576
|
+
skip_value = action is not None and action.nargs != 0
|
|
1465
1577
|
continue
|
|
1466
1578
|
first_cmd = token
|
|
1467
1579
|
first_cmd_index = index
|
|
@@ -1495,7 +1607,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
1495
1607
|
"matrix": "项目级攻防渗透审计已统一收敛至: bugx audit",
|
|
1496
1608
|
"console": "启动统一 Web 控制台与报告预览请使用: bugx report serve",
|
|
1497
1609
|
"watch": "实时流式监视日志与 MCP 工具调用请使用: bugx log --watch",
|
|
1498
|
-
"test": "
|
|
1610
|
+
"test": "单元测试与提交门禁已从当前发行版移除",
|
|
1499
1611
|
}
|
|
1500
1612
|
if first_cmd in removed_map:
|
|
1501
1613
|
print(
|
|
@@ -1506,7 +1618,6 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
1506
1618
|
)
|
|
1507
1619
|
return 2
|
|
1508
1620
|
|
|
1509
|
-
parser = build_parser()
|
|
1510
1621
|
parse_tokens = argv
|
|
1511
1622
|
if first_cmd == "engine":
|
|
1512
1623
|
routed = _route_engine_help_tokens(raw_tokens, first_cmd_index)
|
|
@@ -1519,7 +1630,21 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
1519
1630
|
return 0
|
|
1520
1631
|
if args.command == "help":
|
|
1521
1632
|
return command_help(parser, args)
|
|
1522
|
-
|
|
1633
|
+
try:
|
|
1634
|
+
if args.command == "engine":
|
|
1635
|
+
system.normalize_engine_target(args)
|
|
1636
|
+
if system.forwarded_help(args.engine_args):
|
|
1637
|
+
return system.command_engine(args)
|
|
1638
|
+
args.root = resolve_project_root(args.root)
|
|
1639
|
+
if args.command == "supervisor":
|
|
1640
|
+
if system.forwarded_help(args.supervisor_args):
|
|
1641
|
+
return system.supervisor_help(args.supervisor_command)
|
|
1642
|
+
system.normalize_supervisor_target(args)
|
|
1643
|
+
except CliError as exc:
|
|
1644
|
+
parser.error(str(exc))
|
|
1645
|
+
root = Path(getattr(args, "root", None) or Path.cwd()).expanduser().resolve()
|
|
1646
|
+
if getattr(args, "root", None) is not None:
|
|
1647
|
+
args.root = root
|
|
1523
1648
|
defer_logging = _defer_command_logging_until_authorized(args)
|
|
1524
1649
|
logger = None if defer_logging else _configure_logging(
|
|
1525
1650
|
root, getattr(args, "command", "unknown"), args.log_level,
|
|
@@ -1543,13 +1668,9 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
1543
1668
|
)
|
|
1544
1669
|
if (args.command != "completion" and not read_only_version_check
|
|
1545
1670
|
and not installation_only_diagnosis):
|
|
1546
|
-
#
|
|
1547
|
-
# cannot swallow a missing asset error and accidentally skip the
|
|
1548
|
-
# one-shot CLI recovery path.
|
|
1549
|
-
# Installation-only doctor is the diagnostic escape hatch: it
|
|
1550
|
-
# reports broken assets itself and must remain runnable when the
|
|
1551
|
-
# central resource gate cannot import the engine.
|
|
1671
|
+
# Installation-only doctor remains available when assets are broken.
|
|
1552
1672
|
_ensure_core_importable()
|
|
1673
|
+
_maybe_report_installation(args.command)
|
|
1553
1674
|
if args.command == "probe":
|
|
1554
1675
|
probe_args = getattr(args, "probe_args", [])
|
|
1555
1676
|
result = int(command_probe(args, probe_args))
|
|
@@ -1564,31 +1685,13 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
1564
1685
|
exit_code=result)
|
|
1565
1686
|
return result
|
|
1566
1687
|
except MissingAgentAssetError as exc:
|
|
1567
|
-
if (argv is None and exc.repairable and not read_only_version_check
|
|
1568
|
-
and os.environ.get(_ASSET_REPAIR_ATTEMPT_ENV) != "1"):
|
|
1569
|
-
try:
|
|
1570
|
-
detail = repair_cli_agent_assets(channel="stable", root=root)
|
|
1571
|
-
print(f"[bugx] {detail};正在重启原命令以加载新安装...", file=sys.stderr)
|
|
1572
|
-
restart_cli_after_asset_repair()
|
|
1573
|
-
except Exception as repair_exc: # noqa: BLE001
|
|
1574
|
-
if logger is not None and args.command != "reset":
|
|
1575
|
-
logging_module.log_event(
|
|
1576
|
-
logger, "asset_repair_failed", str(repair_exc), level=40,
|
|
1577
|
-
command=args.command, failure_kind=type(repair_exc).__name__,
|
|
1578
|
-
)
|
|
1579
|
-
print(f"[bugx] ✗ {exc}", file=sys.stderr)
|
|
1580
|
-
print(f"[bugx] ✗ 安全自愈未完成:{repair_exc}", file=sys.stderr)
|
|
1581
|
-
print(
|
|
1582
|
-
" 可在发布服务恢复后重试,或先安装经过校验的 bugx-agent wheel。",
|
|
1583
|
-
file=sys.stderr,
|
|
1584
|
-
)
|
|
1585
|
-
return 2
|
|
1586
|
-
|
|
1587
1688
|
if logger is not None and args.command != "reset":
|
|
1588
1689
|
logging_module.log_event(logger, "command_failed", str(exc),
|
|
1589
1690
|
level=40, command=args.command,
|
|
1590
1691
|
failure_kind="agent_assets_missing")
|
|
1591
1692
|
print(f"[bugx] ✗ {exc}", file=sys.stderr)
|
|
1693
|
+
if exc.repairable:
|
|
1694
|
+
print(" 可显式运行 bugx update --repair-assets 修复安装资源。", file=sys.stderr)
|
|
1592
1695
|
advice = _generate_ai_exception_advice(exc, getattr(args, "command", None))
|
|
1593
1696
|
if advice:
|
|
1594
1697
|
print(f" 💡 AI 解决建议: {advice}", file=sys.stderr)
|
|
@@ -1596,7 +1699,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
1596
1699
|
except CliError as exc:
|
|
1597
1700
|
from .infra.ai_advisor import RuntimeSelfHealInterceptor
|
|
1598
1701
|
interceptor = RuntimeSelfHealInterceptor(root)
|
|
1599
|
-
if interceptor.can_heal(exc, command=args.command):
|
|
1702
|
+
if not defer_logging and interceptor.can_heal(exc, command=args.command):
|
|
1600
1703
|
print(f"[bugx] ⚠️ 检测到命令 '{args.command}' 执行中断: {exc}", file=sys.stderr)
|
|
1601
1704
|
heal_ok, heal_detail = interceptor.try_heal(exc, command=args.command)
|
|
1602
1705
|
if heal_ok:
|
|
@@ -25,7 +25,7 @@ def command_advisory(args: argparse.Namespace) -> int:
|
|
|
25
25
|
if subcommand == "list":
|
|
26
26
|
# Look for existing advisories in standard locations
|
|
27
27
|
candidates = [
|
|
28
|
-
Path.cwd() / "evals" / "oss" / "ghsa_advisories.json",
|
|
28
|
+
Path.cwd() / "verification" / "evals" / "oss" / "ghsa_advisories.json",
|
|
29
29
|
Path.cwd() / ".bugx" / "advisories.json",
|
|
30
30
|
]
|
|
31
31
|
found = False
|