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
|
@@ -584,6 +584,23 @@ _report_policy_startup_gate = report_policy_startup_gate
|
|
|
584
584
|
_interactive_startup_decisions = interactive_startup_decisions
|
|
585
585
|
|
|
586
586
|
|
|
587
|
+
def _map_coverage_bootstrap_answer(value: str | None) -> bool | None:
|
|
588
|
+
"""coverage_bootstrap 选择值→动作映射单一真源(TTY / 信箱两通道共用)。
|
|
589
|
+
|
|
590
|
+
TTY 文本菜单经 ``ask_interaction`` 返回选项序号("1"/"2");信箱通道
|
|
591
|
+
(``bugx interaction answer coverage_bootstrap``)经 ``take_answer`` 返回
|
|
592
|
+
结构化门禁的语义 value("bootstrap"/"later")。两通道必须落到同一动作,
|
|
593
|
+
否则语义答案会在 ask 内被消费(consumed_at 已置位)却被映射丢弃,
|
|
594
|
+
门禁无限重发。
|
|
595
|
+
"""
|
|
596
|
+
low = (value or "").strip().lower()
|
|
597
|
+
if low in {"1", "bootstrap"}:
|
|
598
|
+
return True
|
|
599
|
+
if low in {"2", "later"}:
|
|
600
|
+
return False
|
|
601
|
+
return None
|
|
602
|
+
|
|
603
|
+
|
|
587
604
|
def _ask_coverage_bootstrap() -> bool | None:
|
|
588
605
|
"""通过统一组件询问是否创建覆盖清单。"""
|
|
589
606
|
result = ask_interaction(
|
|
@@ -593,12 +610,7 @@ def _ask_coverage_bootstrap() -> bool | None:
|
|
|
593
610
|
],
|
|
594
611
|
default=0,
|
|
595
612
|
)
|
|
596
|
-
|
|
597
|
-
if value == "1":
|
|
598
|
-
return True
|
|
599
|
-
if value == "2":
|
|
600
|
-
return False
|
|
601
|
-
return None
|
|
613
|
+
return _map_coverage_bootstrap_answer(answered_value(result))
|
|
602
614
|
|
|
603
615
|
#: 显式审计范围入口(`autonomous --coverage-manifest` / 手工 ``BUGX_COVERAGE_MANIFEST``)。
|
|
604
616
|
#:
|
|
@@ -826,6 +838,23 @@ def coverage_startup_gate(
|
|
|
826
838
|
)
|
|
827
839
|
return 0
|
|
828
840
|
|
|
841
|
+
def _map_aborted_session_answer(value: str | None) -> str | None:
|
|
842
|
+
"""aborted_session 选择值→动作映射单一真源(TTY / 信箱两通道共用)。
|
|
843
|
+
|
|
844
|
+
TTY 文本菜单经 ``ask_interaction`` 返回选项序号("1"/"2");信箱通道
|
|
845
|
+
(``bugx interaction answer aborted_session``)经 ``take_answer`` 返回
|
|
846
|
+
结构化门禁的语义 value("resume"/"new")。两通道必须落到同一动作,
|
|
847
|
+
否则语义答案会在 ask 内被消费(consumed_at 已置位)却被映射丢弃,
|
|
848
|
+
门禁无限重发。
|
|
849
|
+
"""
|
|
850
|
+
low = (value or "").strip().lower()
|
|
851
|
+
if low in {"1", "resume"}:
|
|
852
|
+
return "resume"
|
|
853
|
+
if low in {"2", "new"}:
|
|
854
|
+
return "new"
|
|
855
|
+
return None
|
|
856
|
+
|
|
857
|
+
|
|
829
858
|
def _ask_aborted_session_choice() -> str | None:
|
|
830
859
|
"""通过统一组件询问已中断会话的显式去向:恢复或新建。"""
|
|
831
860
|
result = ask_interaction(
|
|
@@ -835,8 +864,7 @@ def _ask_aborted_session_choice() -> str | None:
|
|
|
835
864
|
],
|
|
836
865
|
default=0,
|
|
837
866
|
)
|
|
838
|
-
|
|
839
|
-
return {"1": "resume", "2": "new"}.get(value or "")
|
|
867
|
+
return _map_aborted_session_answer(answered_value(result))
|
|
840
868
|
|
|
841
869
|
def aborted_session_gate(
|
|
842
870
|
previous_runtime: dict, explicit_choice: str | None = None, *,
|
|
@@ -483,6 +483,53 @@ def save_strategy_draft(plan: dict[str, Any]) -> None:
|
|
|
483
483
|
secure_atomic.atomic_write_json(draft_file, plan, mode=0o600, parent_mode=0o700)
|
|
484
484
|
print(f"[launch_bugx] 作战方案已暂存至 {draft_file},本轮启动停止。")
|
|
485
485
|
|
|
486
|
+
def _apply_strategy_choice(
|
|
487
|
+
choice: str | None, plan: dict[str, Any], *, cli_fix_mode: str | None = None,
|
|
488
|
+
) -> tuple[int, str | None] | None:
|
|
489
|
+
"""把 strategy_plan 选择值映射为统一动作(flag / TTY / 信箱三通道共用)。
|
|
490
|
+
|
|
491
|
+
返回 ``(code, decision)``;不匹配任何合法值时返回 ``None``(调用方继续
|
|
492
|
+
走发问路径)。值集与三个历史通道逐字保持一致,禁止在调用方再写第二份。
|
|
493
|
+
"""
|
|
494
|
+
choice = (choice or "").strip().lower()
|
|
495
|
+
if choice in {"approve", "approve_and_start", "1"}:
|
|
496
|
+
target = _get_sg_attr("_apply_approved_strategy") or _apply_approved_strategy
|
|
497
|
+
target(plan, cli_fix_mode=cli_fix_mode)
|
|
498
|
+
return 0, "approved"
|
|
499
|
+
if choice in {"customize", "custom", "2"}:
|
|
500
|
+
target = _get_sg_attr("mark_strategy_customized") or mark_strategy_customized
|
|
501
|
+
target(plan)
|
|
502
|
+
return 0, "customized"
|
|
503
|
+
if choice in {"later", "save_and_later", "save", "3"}:
|
|
504
|
+
target = _get_sg_attr("_save_strategy_draft") or _save_strategy_draft
|
|
505
|
+
target(plan)
|
|
506
|
+
return POLLING_DECISION_REQUIRED, "later"
|
|
507
|
+
return None
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
def _startup_mailbox_answer(gate: str) -> str | None:
|
|
511
|
+
"""消费一条启动门禁的信箱答案(与 ``interaction.ask()`` 通道对称)。
|
|
512
|
+
|
|
513
|
+
仅 ``ANSWERED`` 返回 value;``NONE``/``INVALID``/``CANCELLED`` 一律返回
|
|
514
|
+
``None``(INVALID 不消费、宿主可重新提交正确取值;CANCELLED 视为未回答,
|
|
515
|
+
门禁照常重发——契约是「停留在当前 gate」)。统一交互组件不可用时静默
|
|
516
|
+
返回 ``None``,不得抛错阻断启动。
|
|
517
|
+
"""
|
|
518
|
+
try:
|
|
519
|
+
from core.runtime import interaction_store
|
|
520
|
+
except (ImportError, OSError, RuntimeError, ValueError):
|
|
521
|
+
return None
|
|
522
|
+
if not interaction_store.is_available():
|
|
523
|
+
return None
|
|
524
|
+
try:
|
|
525
|
+
lookup = interaction_store.take_answer(gate, "startup")
|
|
526
|
+
except (OSError, ValueError, RuntimeError):
|
|
527
|
+
return None
|
|
528
|
+
if lookup.status == interaction_store.ANSWERED and isinstance(lookup.value, str):
|
|
529
|
+
return lookup.value
|
|
530
|
+
return None
|
|
531
|
+
|
|
532
|
+
|
|
486
533
|
def strategy_plan_gate(
|
|
487
534
|
strategy_choice: str | None = None,
|
|
488
535
|
environment=None,
|
|
@@ -498,18 +545,9 @@ def strategy_plan_gate(
|
|
|
498
545
|
plan = plan_data or compile_strategy_plan(root)
|
|
499
546
|
|
|
500
547
|
choice = (strategy_choice or "").strip().lower()
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
return 0, "approved"
|
|
505
|
-
if choice in {"customize", "custom", "2"}:
|
|
506
|
-
target = _get_sg_attr("mark_strategy_customized") or mark_strategy_customized
|
|
507
|
-
target(plan)
|
|
508
|
-
return 0, "customized"
|
|
509
|
-
if choice in {"later", "save_and_later", "save", "3"}:
|
|
510
|
-
target = _get_sg_attr("_save_strategy_draft") or _save_strategy_draft
|
|
511
|
-
target(plan)
|
|
512
|
-
return POLLING_DECISION_REQUIRED, "later"
|
|
548
|
+
applied = _apply_strategy_choice(choice, plan, cli_fix_mode=cli_fix_mode)
|
|
549
|
+
if applied is not None:
|
|
550
|
+
return applied
|
|
513
551
|
|
|
514
552
|
runtime = load_runtime()
|
|
515
553
|
saved_status = (runtime.get("strategy_plan") or {}).get("status")
|
|
@@ -561,6 +599,18 @@ def strategy_plan_gate(
|
|
|
561
599
|
return POLLING_DECISION_REQUIRED, "later"
|
|
562
600
|
return POLLING_DECISION_REQUIRED, None
|
|
563
601
|
|
|
602
|
+
# 信箱回灌(F-RSI-20261118-001):无 TTY 宿主经 ``bugx interaction answer
|
|
603
|
+
# strategy_plan --value <v>`` 回灌的答案此前在 emit_startup_gate 直发路径上
|
|
604
|
+
# 永远无人消费(真机实证 consumed_at=null,宿主被迫用 --strategy-plan flag
|
|
605
|
+
# 绕过)。在此消费并复用与 flag/TTY 完全相同的值映射;非法值不消费
|
|
606
|
+
# (take_answer 契约),门禁照常重发(fail-closed)。
|
|
607
|
+
mailbox_value = _startup_mailbox_answer("strategy_plan")
|
|
608
|
+
if mailbox_value is not None:
|
|
609
|
+
mailbox_applied = _apply_strategy_choice(
|
|
610
|
+
mailbox_value, plan, cli_fix_mode=cli_fix_mode,
|
|
611
|
+
)
|
|
612
|
+
if mailbox_applied is not None:
|
|
613
|
+
return mailbox_applied
|
|
564
614
|
emit_startup_gate(
|
|
565
615
|
"strategy_plan",
|
|
566
616
|
plan["summary"],
|
|
@@ -838,6 +888,12 @@ def report_policy_startup_gate(
|
|
|
838
888
|
if policy is None:
|
|
839
889
|
return POLLING_DECISION_REQUIRED, None
|
|
840
890
|
return 0, policy
|
|
891
|
+
# 信箱回灌(F-RSI-20261118-001,与 strategy_plan 同型):仅在非 blocked 的
|
|
892
|
+
# 非 TTY 路径消费——blocked 环境维持 F-RSI-20261110-004 的 local 最小权限
|
|
893
|
+
# 默认(report_policy 是隐私出口,陈旧信箱 submit 不得在无交互环境放大外发)。
|
|
894
|
+
mailbox_value = _startup_mailbox_answer("report_policy")
|
|
895
|
+
if mailbox_value in {"none", "local", "submit"}:
|
|
896
|
+
return 0, mailbox_value
|
|
841
897
|
emit_startup_gate(
|
|
842
898
|
"report_policy",
|
|
843
899
|
"审计报告如何处置?",
|
|
@@ -167,7 +167,7 @@ def normalize_cli_version(value: str) -> str | None:
|
|
|
167
167
|
"""Normalize a BugX/Python version to the compatibility contract version.
|
|
168
168
|
|
|
169
169
|
委托 :func:`bugx_paths.contract_version`(唯一实现)。历史缺陷:此处曾把
|
|
170
|
-
``+build`` 保留在 base 组里,于是 ``1.
|
|
170
|
+
``+build`` 保留在 base 组里,于是 ``0.1.1+2`` 与 ``0.1.1`` 被判为不一致并
|
|
171
171
|
**拒绝启动**,而 ``bugx doctor`` 用另一套规则判为"一致"——同一份清单、两个
|
|
172
172
|
相反结论。归一化规则只能有一处,否则两边必然再次漂移。
|
|
173
173
|
"""
|
|
@@ -234,9 +234,15 @@ def version_marker(path: Path) -> str | None:
|
|
|
234
234
|
return None
|
|
235
235
|
match = re.search(
|
|
236
236
|
r"(?:bugx_version[\"']?\s*:\s*[\"']?|^version:\s*)"
|
|
237
|
-
r"([0-9]+\.[0-9]+\.[0-9]+(?:\+[0-9A-Za-z.-]+)
|
|
237
|
+
r"([0-9]+\.[0-9]+\.[0-9]+(?:\+[0-9A-Za-z.-]+)?|\$\{BUGX_VERSION\})",
|
|
238
|
+
text, re.MULTILINE,
|
|
238
239
|
)
|
|
239
|
-
|
|
240
|
+
if not match:
|
|
241
|
+
return None
|
|
242
|
+
value = match.group(1)
|
|
243
|
+
if value == "0.1.2":
|
|
244
|
+
value = os.environ.get("BUGX_VERSION", "0.1.2")
|
|
245
|
+
return value
|
|
240
246
|
|
|
241
247
|
def startup_release_version(value: object) -> tuple[int, int, int] | None:
|
|
242
248
|
"""Parse the strict x.y.z release format used by the update endpoint."""
|
|
@@ -726,9 +732,13 @@ def startup_remote_version_check(*, stream=None) -> None:
|
|
|
726
732
|
cli_ver = cloud_client.__version__
|
|
727
733
|
if cli_ver == "unknown":
|
|
728
734
|
cli_ver = ""
|
|
735
|
+
client_kind = "npm" if os.environ.get("BUGX_CLI_SOURCE", "").strip().lower() == "npm" else "pip"
|
|
736
|
+
artifact_kind = "npm-tarball" if client_kind == "npm" else "python-wheel"
|
|
729
737
|
result = client.check_version(
|
|
730
738
|
current_version=cli_ver,
|
|
731
739
|
channel=client_metadata.release_channel(),
|
|
740
|
+
client_kind=client_kind,
|
|
741
|
+
artifact_kind=artifact_kind,
|
|
732
742
|
)
|
|
733
743
|
if not result.ok:
|
|
734
744
|
_record_remote_version_result(
|
|
@@ -35,6 +35,7 @@ from core.launch_phases.common import (
|
|
|
35
35
|
child_environment,
|
|
36
36
|
run_child,
|
|
37
37
|
run_bounded,
|
|
38
|
+
sync_codebase_memory_env as _sync_codebase_memory_env,
|
|
38
39
|
bugx_paths,
|
|
39
40
|
)
|
|
40
41
|
import hashlib
|
|
@@ -272,6 +273,25 @@ def auto_recover_supervisor(
|
|
|
272
273
|
current = dict(snapshot) if isinstance(snapshot, Mapping) else {}
|
|
273
274
|
if not current.get("parallel_gate") or "next_action" not in current:
|
|
274
275
|
current = _supervisor_recovery_snapshot(supervisor)
|
|
276
|
+
# F-RSI-20261110-035:外部快照必须带 state 子对象——预算重置的参数
|
|
277
|
+
# 继承(max_rounds/max_wall_seconds/...)从 current["state"]["budget"]
|
|
278
|
+
# 读取;缺 state 时旧实现静默用默认值重置(红探针实测预算键全部丢失,
|
|
279
|
+
# 返回 "recovered" 伪装健康)。内部路径经 _supervisor_recovery_snapshot
|
|
280
|
+
# 构造(缺 state/gate 会 ValueError fail-closed),只有外部传入的
|
|
281
|
+
# snapshot 需要这道闸。
|
|
282
|
+
if isinstance(snapshot, Mapping) and not isinstance(current.get("state"), Mapping):
|
|
283
|
+
detail = (
|
|
284
|
+
"外部快照缺少 state 子对象:预算参数继承无法保证,"
|
|
285
|
+
"拒绝自动恢复(fail-closed)"
|
|
286
|
+
)
|
|
287
|
+
print(f"[supervisor] ✗ 自动恢复拒绝: {detail}")
|
|
288
|
+
return {
|
|
289
|
+
"status": "blocked",
|
|
290
|
+
"reason": "recovery_snapshot_missing_state",
|
|
291
|
+
"detail": detail,
|
|
292
|
+
"snapshot": current,
|
|
293
|
+
"events": [],
|
|
294
|
+
}
|
|
275
295
|
|
|
276
296
|
gate = current.get("parallel_gate")
|
|
277
297
|
gate = gate if isinstance(gate, Mapping) else {}
|
|
@@ -741,15 +761,6 @@ def _preflight_probe_summary(report: dict) -> str:
|
|
|
741
761
|
return f"{status}{suffix}{detail}"
|
|
742
762
|
|
|
743
763
|
|
|
744
|
-
def _sync_codebase_memory_env(profile: dict) -> None:
|
|
745
|
-
"""把 codebase-memory 探针结论同步到进程环境变量。"""
|
|
746
|
-
cb_probe = (profile.get("probes") or {}).get("codebase-memory")
|
|
747
|
-
if isinstance(cb_probe, dict):
|
|
748
|
-
os.environ["BUGX_USE_CODEBASE_MEMORY"] = (
|
|
749
|
-
"1" if cb_probe.get("status") == "READY" else "0"
|
|
750
|
-
)
|
|
751
|
-
|
|
752
|
-
|
|
753
764
|
# DES-13:启动前探针的执行真源已收敛到 probe_registry.preflight_probes(),
|
|
754
765
|
# 下列名称不再包含任何手写探针逻辑。它们仅为保持历史导入方
|
|
755
766
|
# (round_orchestrator 仍在 import 这些名字)可用而保留;一旦被真正调用,
|
|
@@ -991,6 +1002,31 @@ def host_entry_gate() -> int:
|
|
|
991
1002
|
return RESTART_REQUIRED
|
|
992
1003
|
|
|
993
1004
|
|
|
1005
|
+
def _map_supervisor_mcp_answer(value: str | None, *, allow_manual: bool = True) -> str | None:
|
|
1006
|
+
"""supervisor_mcp 选择值→动作映射单一真源(TTY / 信箱两通道共用)。
|
|
1007
|
+
|
|
1008
|
+
TTY 文本菜单经 ``ask_interaction`` 返回选项序号("1"/"2"/"3");信箱通道
|
|
1009
|
+
(``bugx interaction answer supervisor_mcp``)经 ``take_answer`` 返回结构化
|
|
1010
|
+
门禁的语义 value("install"/"manual"/"later")。两通道必须落到同一动作,
|
|
1011
|
+
否则语义答案会在 ask 内被消费(consumed_at 已置位)却被映射丢弃,门禁
|
|
1012
|
+
无限重发。
|
|
1013
|
+
"""
|
|
1014
|
+
low = (value or "").strip().lower()
|
|
1015
|
+
if low in {"1", "install"}:
|
|
1016
|
+
return "install"
|
|
1017
|
+
if low == "2":
|
|
1018
|
+
# 序号是位置语义:两选项形状(无 manual)的 "2" 就是 later。
|
|
1019
|
+
return "manual" if allow_manual else "later"
|
|
1020
|
+
if low == "manual":
|
|
1021
|
+
# 语义值只在三选项形状存在;两选项门禁收到过期 manual 必须 fail-closed。
|
|
1022
|
+
return "manual" if allow_manual else None
|
|
1023
|
+
if low == "3":
|
|
1024
|
+
return "later" if allow_manual else None
|
|
1025
|
+
if low == "later":
|
|
1026
|
+
return "later"
|
|
1027
|
+
return None
|
|
1028
|
+
|
|
1029
|
+
|
|
994
1030
|
def _prompt_supervisor_mcp(
|
|
995
1031
|
status: dict[str, object], *, allow_manual: bool = True,
|
|
996
1032
|
) -> str | None:
|
|
@@ -1009,14 +1045,7 @@ def _prompt_supervisor_mcp(
|
|
|
1009
1045
|
+ "。完成后必须重启宿主,再在新会话重新启动 BugX。"
|
|
1010
1046
|
),
|
|
1011
1047
|
)
|
|
1012
|
-
|
|
1013
|
-
if value == "1":
|
|
1014
|
-
return "install"
|
|
1015
|
-
if allow_manual and value == "2":
|
|
1016
|
-
return "manual"
|
|
1017
|
-
if value == ("3" if allow_manual else "2"):
|
|
1018
|
-
return "later"
|
|
1019
|
-
return None
|
|
1048
|
+
return _map_supervisor_mcp_answer(answered_value(result), allow_manual=allow_manual)
|
|
1020
1049
|
|
|
1021
1050
|
def supervisor_mcp_gate(*, review_mode: str | None,
|
|
1022
1051
|
autonomous: bool = False) -> str:
|
|
@@ -392,8 +392,14 @@ def bootstrap_coverage_manifest_locked(manifest: Path) -> bool:
|
|
|
392
392
|
with open(manifest, "a", encoding="utf-8") as f:
|
|
393
393
|
for bl in business_lines:
|
|
394
394
|
f.write(bl + "\n")
|
|
395
|
-
except Exception:
|
|
396
|
-
|
|
395
|
+
except Exception as exc:
|
|
396
|
+
# F-RSI-20261113-109:业务链路追加失败不得静默——清单缺业务行是
|
|
397
|
+
# 覆盖面缺口(judge 业务链路组合关单与业务单元派发都会错过),
|
|
398
|
+
# 骨架生成整体成功所以 fail-open,但缺口必须可观测(F-104/106 同款)。
|
|
399
|
+
print(
|
|
400
|
+
f"[launch_bugx] ⚠ 业务链路行追加失败,覆盖清单缺业务链路(组合关单/业务派发将错过): {exc}",
|
|
401
|
+
file=sys.stderr,
|
|
402
|
+
)
|
|
397
403
|
print(
|
|
398
404
|
f"[launch_bugx] ✓ 已自动生成覆盖清单骨架:{len(discovered)} 个最小单元"
|
|
399
405
|
"(module_coverage discover;Agent 开工后继续细化难度/工具/业务链路列)"
|
|
@@ -20,6 +20,7 @@ from core.launch_phases.common import (
|
|
|
20
20
|
supervisor_state_path,
|
|
21
21
|
child_environment,
|
|
22
22
|
run_child,
|
|
23
|
+
sync_codebase_memory_env as _sync_codebase_memory_env,
|
|
23
24
|
bugx_paths,
|
|
24
25
|
)
|
|
25
26
|
from core.launch_phases.session_runtime import (
|
|
@@ -595,15 +596,6 @@ def check_fix_regressions(root: Path | None = None) -> dict:
|
|
|
595
596
|
return _watchlist_error_report(exc)
|
|
596
597
|
|
|
597
598
|
|
|
598
|
-
def _sync_codebase_memory_env(profile: dict) -> None:
|
|
599
|
-
"""把 codebase-memory 探针结论同步到进程环境变量。"""
|
|
600
|
-
cb_probe = (profile.get("probes") or {}).get("codebase-memory")
|
|
601
|
-
if isinstance(cb_probe, dict):
|
|
602
|
-
os.environ["BUGX_USE_CODEBASE_MEMORY"] = (
|
|
603
|
-
"1" if cb_probe.get("status") == "READY" else "0"
|
|
604
|
-
)
|
|
605
|
-
|
|
606
|
-
|
|
607
599
|
def report_degraded_probes(*, refresh: bool = False,
|
|
608
600
|
degraded: list[dict] | None = None) -> list[dict]:
|
|
609
601
|
"""收集并显式汇报探针 DEGRADED 项;返回降级动作清单供写入准备记录。
|