bugx-cli 0.1.0 → 0.1.1
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 +190 -186
- 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/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/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/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 +25 -6
- package/core/cloud_sync/cloud_onboard.py +42 -1
- package/core/cloud_sync/flywheel_client.py +16 -7
- 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 +591 -419
- 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 +2 -2
- package/core/launch_phases/SPEC.md +1 -1
- package/core/launch_phases/common.py +21 -2
- package/core/launch_phases/finding_confirm_phase.py +5 -1
- 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 +139 -3
- 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 +53 -36
- package/core/launch_phases/pre_state_builder.py +23 -176
- package/core/launch_phases/round_orchestrator.py +15 -32
- 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 +9 -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/worker_barriers.py +15 -5
- package/core/launch_phases/worker_orchestrator.py +105 -25
- package/core/ledger/README.md +1 -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 +44 -8
- 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 +1 -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 +7 -5
- 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/command_routing_en.md +2 -2
- package/core/prompts/command_routing_zh.md +2 -2
- package/core/prompts/stages/stage_repair.md +1 -1
- 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/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 +1 -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/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/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 +190 -186
- 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 +11 -4
- package/interfaces/cli/bugx_cli/commands/advisory.py +1 -1
- package/interfaces/cli/bugx_cli/commands/agent.py +339 -73
- package/interfaces/cli/bugx_cli/commands/audit.py +2 -2
- package/interfaces/cli/bugx_cli/commands/autonomous.py +1 -1
- package/interfaces/cli/bugx_cli/commands/cloud.py +4 -3
- 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 +2 -0
- package/interfaces/cli/bugx_cli/commands/lifecycle.py +3 -3
- package/interfaces/cli/bugx_cli/commands/plugin.py +55 -20
- 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/report.py +2 -6
- package/interfaces/cli/bugx_cli/commands/system.py +11 -11
- package/interfaces/cli/bugx_cli/common.py +15 -7
- 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 +18 -10
- 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 +2 -1
- package/pyproject.toml +20 -8
- package/scripts/ensure-python.mjs +7 -7
- package/scripts/sync-version.mjs +10 -21
- package/scripts/test-npm-wrapper.mjs +1 -1
- 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
|
@@ -122,7 +122,11 @@ def _print_pending(rows: list[dict[str, Any]], root: Path) -> None:
|
|
|
122
122
|
def _command_list(args: argparse.Namespace, store: Any, root: Path) -> int:
|
|
123
123
|
rows = [_question_summary(record) for record in store.list_records(root)]
|
|
124
124
|
if not getattr(args, "all", False):
|
|
125
|
-
|
|
125
|
+
# 默认列出「尚未消费」的问题:created 无 answer(全新待答)、
|
|
126
|
+
# answered 有 pending 答案(待宿主回灌)都属于未消费;只有 consumed
|
|
127
|
+
# (有 answers 且无 pending)才隐藏。原条件 answered or cancelled 恰好
|
|
128
|
+
# 把全新问题排除、把已消费问题留下,与本命令帮助语义相反。
|
|
129
|
+
rows = [row for row in rows if not row["consumed"]]
|
|
126
130
|
if getattr(args, "json", False):
|
|
127
131
|
_emit_json({"status": "ok", "root": str(root), "count": len(rows), "questions": rows})
|
|
128
132
|
return 0
|
|
@@ -600,6 +600,8 @@ def command_knowledge(args: argparse.Namespace) -> int:
|
|
|
600
600
|
raise CliError(_i18n_exc("knowledge.export_output_required", "knowledge export 必须提供 --output"))
|
|
601
601
|
values.extend(["--output", str(_rooted(root, args.output)),
|
|
602
602
|
"--contributor", args.contributor])
|
|
603
|
+
if getattr(args, "include_source_snippets", False):
|
|
604
|
+
values.append("--include-source-snippets")
|
|
603
605
|
elif command == "approve":
|
|
604
606
|
if args.bundle is None or args.output is None or not args.reviewer or not args.reason:
|
|
605
607
|
raise CliError(_i18n_exc("knowledge.approve_params_required", "knowledge approve 必须提供 --bundle、--output、--reviewer、--reason"))
|
|
@@ -1734,11 +1734,11 @@ def _self_uninstall_flow(args: argparse.Namespace, root: Path) -> int:
|
|
|
1734
1734
|
|
|
1735
1735
|
cli_source = os.environ.get("BUGX_CLI_SOURCE", "")
|
|
1736
1736
|
if cli_source == "npm" or "bin/bugx.js" in sys.argv[0]:
|
|
1737
|
-
next_step = "如需移除 CLI 本体:npm uninstall -g
|
|
1737
|
+
next_step = "如需移除 CLI 本体:npm uninstall -g bugx-cli"
|
|
1738
1738
|
elif "uv/tools" in sys.executable or "uv/tools" in sys.argv[0] or ".local/share/uv" in sys.executable:
|
|
1739
|
-
next_step = "如需移除 CLI 本体:uv tool uninstall bugx-
|
|
1739
|
+
next_step = "如需移除 CLI 本体:uv tool uninstall bugx-cli"
|
|
1740
1740
|
else:
|
|
1741
|
-
next_step = "如需移除 CLI 本体:pip uninstall bugx-
|
|
1741
|
+
next_step = "如需移除 CLI 本体:pip uninstall bugx-cli(若使用 npm,运行 npm uninstall -g bugx-cli)"
|
|
1742
1742
|
|
|
1743
1743
|
payload = {
|
|
1744
1744
|
"status": "UNINSTALLED",
|
|
@@ -727,6 +727,11 @@ def _host_supervisor_server_definitions(
|
|
|
727
727
|
|
|
728
728
|
每个宿主的配置只写在当前项目中,server 命令统一以 ``--root .``
|
|
729
729
|
绑定宿主打开的工作区。
|
|
730
|
+
|
|
731
|
+
例外:宿主插件声明 ``mcp_write.requires_absolutize=True`` 时(pi/claude 等,
|
|
732
|
+
写入分支见 :func:`write_host_mcp_config`),落盘前由
|
|
733
|
+
:func:`_absolutize_server_definitions` 把 ``--root``/``--db``/command 绝对化——
|
|
734
|
+
这类宿主由宿主进程 spawn MCP,cwd 不可依赖。
|
|
730
735
|
"""
|
|
731
736
|
if shape not in _mcp_shape_names():
|
|
732
737
|
raise CliError(_i18n_exc("plugin.unknown_mcp_shape", f"未知宿主 MCP 配置形态: {shape}", shape=shape))
|
|
@@ -855,6 +860,33 @@ def _absolutize_server_definitions(
|
|
|
855
860
|
return desired
|
|
856
861
|
|
|
857
862
|
|
|
863
|
+
def _mcp_entry_has_relative_paths(entry: object) -> bool:
|
|
864
|
+
"""宿主 MCP 条目 argv 是否仍携带相对 ``--root`` / ``--db`` 路径 token。
|
|
865
|
+
|
|
866
|
+
``mcp_write.requires_absolutize=True`` 宿主的**声明性过期**判据:这类宿主的
|
|
867
|
+
stdio MCP server 由宿主进程 spawn,cwd 不是工作区,相对 ``--root .`` 会解析
|
|
868
|
+
到宿主自己的目录而不是本项目(dsh/pi 实测同一陷阱,D3 遗留修复的过期语义)。
|
|
869
|
+
磁盘条目只要还是相对形态就判过期,触发重写为绝对根;绝对形态交给
|
|
870
|
+
``_host_mcp_entry_is_current`` 按 root 感知的 pinned 语义比对(幂等判定)。
|
|
871
|
+
"""
|
|
872
|
+
if not isinstance(entry, dict):
|
|
873
|
+
return False
|
|
874
|
+
args = entry.get("args")
|
|
875
|
+
if not isinstance(args, list):
|
|
876
|
+
return False
|
|
877
|
+
for index, token in enumerate(args):
|
|
878
|
+
if index + 1 >= len(args):
|
|
879
|
+
continue
|
|
880
|
+
value = args[index + 1]
|
|
881
|
+
if not isinstance(value, str):
|
|
882
|
+
continue
|
|
883
|
+
if token == "--root" and not Path(value).is_absolute():
|
|
884
|
+
return True
|
|
885
|
+
if token == "--db" and value.startswith(".bugx/"):
|
|
886
|
+
return True
|
|
887
|
+
return False
|
|
888
|
+
|
|
889
|
+
|
|
858
890
|
def _zcode_mcp_container_key() -> str:
|
|
859
891
|
"""ZCode MCP 容器的点分键;来自插件 ``mcp_write.container_key``(唯一事实)。"""
|
|
860
892
|
|
|
@@ -1303,17 +1335,13 @@ def write_host_mcp_config(
|
|
|
1303
1335
|
desired = _host_supervisor_server_definitions(
|
|
1304
1336
|
shape=str(host_name).strip().casefold(), optional_names=optional_names,
|
|
1305
1337
|
)
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
payload[servers_key] = servers
|
|
1314
|
-
if not isinstance(servers, dict):
|
|
1315
|
-
raise CliError(_i18n_exc("plugin.claude_servers_not_object", f"Claude Code 配置 {servers_key} 不是对象,拒绝写入: {target}", servers_key=servers_key, target=target))
|
|
1316
|
-
desired = _host_supervisor_server_definitions(shape="claude", optional_names=optional_names)
|
|
1338
|
+
if migrated.requires_absolutize:
|
|
1339
|
+
# 宿主声明 ``requires_absolutize=True`` 时按契约落盘**绝对**根(D3
|
|
1340
|
+
# 遗留修复:通用骨架此前无视该声明写相对 ``--root .``)。这类宿主的
|
|
1341
|
+
# stdio MCP server 由宿主进程 spawn,cwd 不是工作区,相对根会解析到
|
|
1342
|
+
# 宿主目录。语义与 dsh/pi bootstrap 一致:绝对化后同根重跑逐字段
|
|
1343
|
+
# 相等 ⇒ changed=False;换根则按本次根重写。
|
|
1344
|
+
_absolutize_server_definitions(desired, root)
|
|
1317
1345
|
elif host_name == "funide":
|
|
1318
1346
|
target = root / ".mcp.json"
|
|
1319
1347
|
payload = _load_json_object(target, "FunIDE")
|
|
@@ -1325,10 +1353,10 @@ def write_host_mcp_config(
|
|
|
1325
1353
|
if not isinstance(servers, dict):
|
|
1326
1354
|
raise CliError(_i18n_exc("plugin.funide_servers_not_object", f"FunIDE 配置 {servers_key} 不是对象,拒绝写入: {target}", servers_key=servers_key, target=target))
|
|
1327
1355
|
desired = _host_supervisor_server_definitions(shape="funide", optional_names=optional_names)
|
|
1328
|
-
elif host_name in {"
|
|
1356
|
+
elif host_name in {"chatgpt", "workbuddy", "codebuddy"}:
|
|
1357
|
+
# pi / dsh 已迁移为插件:分别走上方通用 JSON 骨架分支(requires_absolutize
|
|
1358
|
+
# 声明绝对化)与全局分支(project_relpath=None),这里的遗留路径已不可达。
|
|
1329
1359
|
target = root / {
|
|
1330
|
-
"pi": ".pi/mcp.json",
|
|
1331
|
-
"dsh": ".dsh/mcp.json",
|
|
1332
1360
|
"chatgpt": ".agents/mcp.json",
|
|
1333
1361
|
"workbuddy": ".workbuddy/mcp.json",
|
|
1334
1362
|
"codebuddy": ".codebuddy/mcp.json",
|
|
@@ -1379,7 +1407,17 @@ def write_host_mcp_config(
|
|
|
1379
1407
|
def _entry_is_current(name: str, current: object) -> bool:
|
|
1380
1408
|
return _absolute_entry_is_current(name, current, desired)
|
|
1381
1409
|
else:
|
|
1382
|
-
|
|
1410
|
+
_absolutize_facet = engine_host_mcp_write(host_name)
|
|
1411
|
+
if _absolutize_facet is not None and _absolutize_facet.requires_absolutize:
|
|
1412
|
+
def _entry_is_current(name: str, current: object) -> bool:
|
|
1413
|
+
# 声明绝对化的宿主(pi/claude…):相对 --root/--db 是声明性过期,
|
|
1414
|
+
# 必须重写为绝对根;绝对形态按 root 感知的 pinned 语义比对——
|
|
1415
|
+
# 同根重跑逐字段相等 ⇒ unchanged(幂等,不依赖 CLI 进程 cwd)。
|
|
1416
|
+
if _mcp_entry_has_relative_paths(current):
|
|
1417
|
+
return False
|
|
1418
|
+
return _host_mcp_entry_is_current(name, current, root)
|
|
1419
|
+
else:
|
|
1420
|
+
_entry_is_current = _host_mcp_entry_is_current
|
|
1383
1421
|
optional_managed = {"playwright", "postmcp"}
|
|
1384
1422
|
for name in optional_managed - set(optional_names or set()):
|
|
1385
1423
|
current = servers.get(name)
|
|
@@ -2051,14 +2089,11 @@ def _host_project_mcp_config_target(root: Path, host_name: str) -> tuple[Path, s
|
|
|
2051
2089
|
migrated = engine_host_mcp_write(host_name)
|
|
2052
2090
|
if migrated is not None and migrated.project_relpath and not migrated.custom_writer:
|
|
2053
2091
|
return root / migrated.project_relpath, migrated.container_key
|
|
2054
|
-
if host_name == "claude":
|
|
2055
|
-
return root / ".mcp.json", "mcpServers"
|
|
2056
2092
|
if host_name == "funide":
|
|
2057
2093
|
return root / ".mcp.json", "mcpServers"
|
|
2058
|
-
if host_name in {"
|
|
2094
|
+
if host_name in {"chatgpt", "workbuddy", "codebuddy"}:
|
|
2095
|
+
# pi / dsh 已迁移(上方插件分支接管),遗留映射仅剩未迁移宿主。
|
|
2059
2096
|
rel_map = {
|
|
2060
|
-
"pi": ".pi/mcp.json",
|
|
2061
|
-
"dsh": ".dsh/mcp.json",
|
|
2062
2097
|
"chatgpt": ".agents/mcp.json",
|
|
2063
2098
|
"workbuddy": ".workbuddy/mcp.json",
|
|
2064
2099
|
"codebuddy": ".codebuddy/mcp.json",
|
|
@@ -249,7 +249,7 @@ _DEFAULT_CLAUDE_SKILL_CONTENT = """---
|
|
|
249
249
|
name: bugx
|
|
250
250
|
description: 专注于代码质量与安全的自主审查智能体。专为深层缺陷排查而生——在功能写完、提 PR 或排查疑难 Bug 时,它能深入分析代码逻辑,自动编写测试用例,挖掘、复现Bug和漏洞,生成经过验证的修复补丁。随时为您的代码质量和代码安全把关。
|
|
251
251
|
metadata:
|
|
252
|
-
bugx_version: "1.
|
|
252
|
+
bugx_version: "0.1.1"
|
|
253
253
|
---
|
|
254
254
|
<!-- bugx-locale: zh-CN -->
|
|
255
255
|
|
|
@@ -257,7 +257,7 @@ metadata:
|
|
|
257
257
|
|
|
258
258
|
BugX Claude Skill 镜像。执行前用 `bugx engine path --name AGENT_GUIDE.md` 和 `bugx engine path --name bugx.md` 读取全局协议;项目 `.bugx/` 只保存状态与配置。
|
|
259
259
|
|
|
260
|
-
协议镜像版本:1.
|
|
260
|
+
协议镜像版本:0.1.1
|
|
261
261
|
|
|
262
262
|
## Claude 原生交互适配(强制)
|
|
263
263
|
|
|
@@ -701,11 +701,11 @@ def _ensure_claude_plugin_registry(
|
|
|
701
701
|
"""在 ~/.claude/plugins 与 ~/.claude/settings.json 中注册 BugX 本地插件与 marketplace。"""
|
|
702
702
|
plugin_dir = _find_or_prepare_plugin_dir(root)
|
|
703
703
|
plugins_dir = _claude_plugins_dir()
|
|
704
|
-
cache_dir = plugins_dir / "cache" / "bugx" / "bugx" /
|
|
704
|
+
cache_dir = plugins_dir / "cache" / "bugx" / "bugx" / __version__
|
|
705
705
|
|
|
706
706
|
now_iso = datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.000Z")
|
|
707
707
|
|
|
708
|
-
# 1.
|
|
708
|
+
# 1. 复制/同步当前版本插件缓存 ~/.claude/plugins/cache/bugx/bugx/<version>
|
|
709
709
|
try:
|
|
710
710
|
cache_dir.mkdir(parents=True, exist_ok=True)
|
|
711
711
|
if plugin_dir and plugin_dir.is_dir():
|
|
@@ -905,7 +905,7 @@ def _ensure_claude_desktop_cowork_plugins(
|
|
|
905
905
|
|
|
906
906
|
m_data: dict[str, object] = {
|
|
907
907
|
"name": marketplace_name,
|
|
908
|
-
"version":
|
|
908
|
+
"version": __version__,
|
|
909
909
|
"description": "Locally uploaded plugins via Claude Desktop app",
|
|
910
910
|
"owner": {"name": "Local User"},
|
|
911
911
|
"plugins": [],
|
|
@@ -923,7 +923,7 @@ def _ensure_claude_desktop_cowork_plugins(
|
|
|
923
923
|
found = False
|
|
924
924
|
for item in plugins_list:
|
|
925
925
|
if isinstance(item, dict) and item.get("name") == "bugx":
|
|
926
|
-
item["version"] =
|
|
926
|
+
item["version"] = __version__
|
|
927
927
|
item["bugx_build_id"] = get_build_id()
|
|
928
928
|
item["source"] = "./bugx"
|
|
929
929
|
found = True
|
|
@@ -931,7 +931,7 @@ def _ensure_claude_desktop_cowork_plugins(
|
|
|
931
931
|
if not found:
|
|
932
932
|
plugins_list.append({
|
|
933
933
|
"name": "bugx",
|
|
934
|
-
"version":
|
|
934
|
+
"version": __version__,
|
|
935
935
|
"bugx_build_id": get_build_id(),
|
|
936
936
|
"source": "./bugx",
|
|
937
937
|
})
|
|
@@ -10,6 +10,7 @@ import urllib.parse
|
|
|
10
10
|
import urllib.request
|
|
11
11
|
from pathlib import Path
|
|
12
12
|
|
|
13
|
+
from .. import __version__
|
|
13
14
|
from ..common import (
|
|
14
15
|
CliError,
|
|
15
16
|
_atomic_write_global_file,
|
|
@@ -326,7 +327,7 @@ def _funide_cloud_request(
|
|
|
326
327
|
"X-Device-Id": "bugx-cli-funide",
|
|
327
328
|
"X-Device-Name": "bugx-cli",
|
|
328
329
|
"X-Platform": sys.platform,
|
|
329
|
-
"X-Client-Version":
|
|
330
|
+
"X-Client-Version": __version__,
|
|
330
331
|
}
|
|
331
332
|
encoded = None
|
|
332
333
|
if body is not None:
|
|
@@ -36,7 +36,7 @@ from ..common import (
|
|
|
36
36
|
# ZCode 官方规范(plugin-creator plugin-json-spec)要求 icon 必须是「可达的
|
|
37
37
|
# HTTPS URL;资产缺失时宁可省略也不得伪造」。此前硬编码的
|
|
38
38
|
# raw.githubusercontent.com/bencibro/bug-hunter 镜像地址不成立:本仓库托管在
|
|
39
|
-
# 私有 Gitea
|
|
39
|
+
# 私有 Gitea(仅 LAN 可达),GitHub 上并无该资产,实测 404,
|
|
40
40
|
# ZCode 渲染器加载失败后回退为通用拼图图标。brand-mark.svg 是 bugx.dev 常驻
|
|
41
41
|
# 的 512×512 官方品牌图标(Cloudflare 分发、content-type 正确),作为插件
|
|
42
42
|
# 图标的权威来源;如后续把 bugx-avatar-512.png 上架官网,只需替换本常量。
|
|
@@ -68,11 +68,7 @@ def command_report(args: argparse.Namespace) -> int:
|
|
|
68
68
|
# 自己的 ``verification/evals/oss/python_all_categories_audit.json``
|
|
69
69
|
# 当成靶场收据,在靶场报告里写出「击杀 42,125 处变异 / 95.23% / ELITE」。
|
|
70
70
|
# 那既不是靶场的测量值,也不是本轮的任何一次执行。
|
|
71
|
-
|
|
72
|
-
project_root / "verification" / "evals" / "oss",
|
|
73
|
-
project_root / "evals" / "oss",
|
|
74
|
-
)
|
|
75
|
-
eval_dir = next((c for c in candidates if c.is_dir()), candidates[-1])
|
|
71
|
+
eval_dir = project_root / "verification" / "evals" / "oss"
|
|
76
72
|
|
|
77
73
|
out_arg = getattr(args, "out", None)
|
|
78
74
|
out_dir = Path(out_arg).resolve() if out_arg else eval_dir
|
|
@@ -85,7 +81,7 @@ def command_report(args: argparse.Namespace) -> int:
|
|
|
85
81
|
|
|
86
82
|
try:
|
|
87
83
|
_ensure_core_importable()
|
|
88
|
-
from
|
|
84
|
+
from ..infra.security import _find_repo_root
|
|
89
85
|
repo_root = _find_repo_root(Path(__file__))
|
|
90
86
|
core_root = repo_root / "core"
|
|
91
87
|
if core_root.is_dir():
|
|
@@ -56,7 +56,7 @@ _ASSET_REPAIR_ATTEMPT_ENV = "BUGX_ASSET_REPAIR_ATTEMPTED"
|
|
|
56
56
|
# Stable package recovery is a separate trust path from the user's configurable
|
|
57
57
|
# knowledge/sync endpoint. Keep it pinned to the production release service.
|
|
58
58
|
_STABLE_AGENT_RELEASE_BASE = "https://bugx.dev"
|
|
59
|
-
_STABLE_AGENT_PYPI_JSON = "https://pypi.org/pypi/bugx-
|
|
59
|
+
_STABLE_AGENT_PYPI_JSON = "https://pypi.org/pypi/bugx-cli/json"
|
|
60
60
|
_STABLE_AGENT_PYPI_HOST = "pypi.org"
|
|
61
61
|
_STABLE_AGENT_FILES_HOST = "files.pythonhosted.org"
|
|
62
62
|
_MAX_PYPI_METADATA_BYTES = 4 * 1024 * 1024
|
|
@@ -379,7 +379,7 @@ def _select_pypi_stable_wheel(payload: object, *, current_version: str) -> dict[
|
|
|
379
379
|
if not isinstance(info, dict) or not isinstance(releases, dict):
|
|
380
380
|
raise CliError("PyPI JSON 缺少 info 或 releases 对象")
|
|
381
381
|
package_name = re.sub(r"[-_.]+", "-", str(info.get("name") or "").strip().lower())
|
|
382
|
-
if package_name != "bugx-
|
|
382
|
+
if package_name != "bugx-cli":
|
|
383
383
|
raise CliError(f"PyPI 返回了错误的发行名:{package_name or '未知'}")
|
|
384
384
|
|
|
385
385
|
candidates: list[tuple[tuple[int, int, int, int, int], dict[str, str]]] = []
|
|
@@ -394,7 +394,7 @@ def _select_pypi_stable_wheel(payload: object, *, current_version: str) -> dict[
|
|
|
394
394
|
or not isinstance(files, list)
|
|
395
395
|
):
|
|
396
396
|
continue
|
|
397
|
-
expected_filename = f"
|
|
397
|
+
expected_filename = f"bugx_cli-{version_text}-py3-none-any.whl"
|
|
398
398
|
matching = [
|
|
399
399
|
item for item in files
|
|
400
400
|
if isinstance(item, dict)
|
|
@@ -599,7 +599,7 @@ def _prepare_cli_package(path: Path) -> Path:
|
|
|
599
599
|
def _installed_cli_distribution_version() -> str | None:
|
|
600
600
|
"""Read the version metadata installed into the interpreter running BugX."""
|
|
601
601
|
try:
|
|
602
|
-
return importlib.metadata.version("bugx-
|
|
602
|
+
return importlib.metadata.version("bugx-cli")
|
|
603
603
|
except importlib.metadata.PackageNotFoundError:
|
|
604
604
|
return None
|
|
605
605
|
|
|
@@ -739,9 +739,9 @@ def _validate_agent_repair_wheel(
|
|
|
739
739
|
metadata = Parser().parsestr(archive.read(metadata_names[0]).decode("utf-8", errors="strict"))
|
|
740
740
|
package_name = re.sub(r"[-_.]+", "-", str(metadata.get("Name") or "")).lower()
|
|
741
741
|
package_version = str(metadata.get("Version") or "").strip()
|
|
742
|
-
if package_name != "bugx-
|
|
742
|
+
if package_name != "bugx-cli" or package_version != expected_version:
|
|
743
743
|
raise CliError(
|
|
744
|
-
f"wheel 身份不匹配:期望 bugx-
|
|
744
|
+
f"wheel 身份不匹配:期望 bugx-cli {expected_version},"
|
|
745
745
|
f"收到 {package_name or '未知包'} {package_version or '未知版本'}"
|
|
746
746
|
)
|
|
747
747
|
|
|
@@ -759,7 +759,7 @@ def _validate_agent_repair_wheel(
|
|
|
759
759
|
f"拒绝 Build ID 降级:最低要求 {minimum_build_id},wheel {wheel_build_id}"
|
|
760
760
|
)
|
|
761
761
|
|
|
762
|
-
engine_prefix = f"
|
|
762
|
+
engine_prefix = f"bugx_cli-{expected_version}.data/data/share/bugx-agent/core/"
|
|
763
763
|
if not any(name.startswith(engine_prefix) for name in names):
|
|
764
764
|
raise CliError("wheel 未包含 share/bugx-agent/core 引擎载荷")
|
|
765
765
|
core_root = extraction_root / "validated-core"
|
|
@@ -889,11 +889,11 @@ def _installed_distribution_core_records(
|
|
|
889
889
|
) -> tuple[dict[str, tuple[str, int]] | None, str]:
|
|
890
890
|
"""Read exact core file hashes from this interpreter's non-editable wheel RECORD."""
|
|
891
891
|
try:
|
|
892
|
-
distribution = importlib.metadata.distribution("bugx-
|
|
892
|
+
distribution = importlib.metadata.distribution("bugx-cli")
|
|
893
893
|
package_name = re.sub(
|
|
894
894
|
r"[-_.]+", "-", str(distribution.metadata.get("Name") or ""),
|
|
895
895
|
).lower()
|
|
896
|
-
if package_name != "bugx-
|
|
896
|
+
if package_name != "bugx-cli" or str(distribution.version) != __version__:
|
|
897
897
|
return None, "当前 distribution 名称或版本与 CLI 不一致"
|
|
898
898
|
record_text = distribution.read_text("RECORD")
|
|
899
899
|
if not record_text:
|
|
@@ -907,7 +907,7 @@ def _installed_distribution_core_records(
|
|
|
907
907
|
if isinstance(dir_info, dict) and dir_info.get("editable") is True:
|
|
908
908
|
return None, "当前安装为 editable,不能用其 RECORD 恢复 wheel 资源"
|
|
909
909
|
except importlib.metadata.PackageNotFoundError:
|
|
910
|
-
return None, "当前 Python 未安装 bugx-
|
|
910
|
+
return None, "当前 Python 未安装 bugx-cli distribution"
|
|
911
911
|
except (OSError, UnicodeError, json.JSONDecodeError, ValueError, TypeError) as exc:
|
|
912
912
|
return None, f"无法读取当前 wheel RECORD:{exc}"
|
|
913
913
|
|
|
@@ -1449,7 +1449,7 @@ def repair_cli_agent_assets(
|
|
|
1449
1449
|
f"资源自动修复后版本不匹配:期望 {latest},实际 {installed_version or '未知'}"
|
|
1450
1450
|
)
|
|
1451
1451
|
try:
|
|
1452
|
-
distribution = importlib.metadata.distribution("bugx-
|
|
1452
|
+
distribution = importlib.metadata.distribution("bugx-cli")
|
|
1453
1453
|
direct_url_text = distribution.read_text("direct_url.json")
|
|
1454
1454
|
direct_url = json.loads(direct_url_text) if direct_url_text else {}
|
|
1455
1455
|
except (importlib.metadata.PackageNotFoundError, json.JSONDecodeError, OSError) as exc:
|
|
@@ -28,9 +28,8 @@ import zipfile
|
|
|
28
28
|
from pathlib import Path
|
|
29
29
|
from typing import Any
|
|
30
30
|
|
|
31
|
-
import bugx_cli
|
|
32
31
|
from . import __version__
|
|
33
|
-
from
|
|
32
|
+
from .infra import (
|
|
34
33
|
CONFIG_NAME,
|
|
35
34
|
CORE_API_RE,
|
|
36
35
|
CliError,
|
|
@@ -197,6 +196,8 @@ PROBE_SCRIPTS = {
|
|
|
197
196
|
"efficiency": "efficiency_probe.py",
|
|
198
197
|
"sast": "sast_probe.py",
|
|
199
198
|
"mobile": "mobile_probe.py",
|
|
199
|
+
"ui": "ui_audit.py",
|
|
200
|
+
"android": "android_probe.py",
|
|
200
201
|
"ios_binary": "ios_binary_probe.py",
|
|
201
202
|
"codebase-memory": "codebase_memory_probe.py",
|
|
202
203
|
"platform": "platform_probe.py",
|
|
@@ -267,7 +268,7 @@ def _ensure_core_importable() -> None:
|
|
|
267
268
|
if cand.is_dir() and (cand / "launch_bugx.py").is_file():
|
|
268
269
|
candidates.append(cand)
|
|
269
270
|
# 后插入者位于 sys.path[0],故按 (asset, global_engine) 顺序插入 ⇒
|
|
270
|
-
# 最终 global_engine 优先。契约见 `docs/03_ai/
|
|
271
|
+
# 最终 global_engine 优先。契约见 `docs/03_ai/01_AI_REFERENCE.md`「副本升级门禁」:
|
|
271
272
|
# Python 导入必须优先 `global_engine_root()`(共享引擎是运行时真源),
|
|
272
273
|
# 仅在全局引擎缺失 launch_bugx.py 时才回落到 asset_root。
|
|
273
274
|
for cand in candidates:
|
|
@@ -858,13 +859,20 @@ def get_build_id() -> int | None:
|
|
|
858
859
|
raise CliError("BUGX_BUILD_ID 超出支持的整数范围") from exc
|
|
859
860
|
if env_value < 1:
|
|
860
861
|
raise CliError("BUGX_BUILD_ID 必须是正整数")
|
|
861
|
-
|
|
862
|
+
# F-RSI-20261110-045:包标识改相对读取——原 `getattr(bugx_cli, "__build_id__")`
|
|
863
|
+
# 依赖顶层模块名 `bugx_cli`,仓库开发布局下该名字解析到 site-packages
|
|
864
|
+
# 安装副本(bugx-agent 1.0.0 快照),__build_id__ 短路劫持到陈旧快照。
|
|
865
|
+
try:
|
|
866
|
+
from . import __build_id__ as _pkg_build_id
|
|
867
|
+
except ImportError:
|
|
868
|
+
_pkg_build_id = None
|
|
869
|
+
build_id = _pkg_build_id if isinstance(_pkg_build_id, int) and not isinstance(_pkg_build_id, bool) and _pkg_build_id >= 1 else None
|
|
862
870
|
if isinstance(build_id, int) and not isinstance(build_id, bool) and build_id >= 1:
|
|
863
871
|
return build_id
|
|
864
872
|
if env_value is not None:
|
|
865
873
|
return env_value
|
|
866
874
|
try:
|
|
867
|
-
from
|
|
875
|
+
from .infra.engine_installer import asset_root
|
|
868
876
|
meta = asset_root() / "metadata.txt"
|
|
869
877
|
if meta.is_file():
|
|
870
878
|
content = meta.read_text(encoding="utf-8")
|
|
@@ -874,7 +882,7 @@ def get_build_id() -> int | None:
|
|
|
874
882
|
except Exception:
|
|
875
883
|
pass
|
|
876
884
|
try:
|
|
877
|
-
from
|
|
885
|
+
from .infra.engine_installer import global_engine_root
|
|
878
886
|
meta = global_engine_root() / "metadata.txt"
|
|
879
887
|
if meta.is_file():
|
|
880
888
|
content = meta.read_text(encoding="utf-8")
|
|
@@ -887,7 +895,7 @@ def get_build_id() -> int | None:
|
|
|
887
895
|
|
|
888
896
|
|
|
889
897
|
def get_full_version() -> str:
|
|
890
|
-
"""返回标准版本与 Build ID 组合字符串,例如 1.
|
|
898
|
+
"""返回标准版本与 Build ID 组合字符串,例如 0.1.1+build.627。"""
|
|
891
899
|
bid = get_build_id()
|
|
892
900
|
if bid is not None:
|
|
893
901
|
return f"{__version__}+build.{bid}"
|
|
@@ -17,6 +17,16 @@ import shutil
|
|
|
17
17
|
import subprocess
|
|
18
18
|
|
|
19
19
|
from .hosts.registry import engine_host_plugin
|
|
20
|
+
from .hosts.template_engine import (
|
|
21
|
+
AGENT_DESCRIPTION,
|
|
22
|
+
AGENT_DESCRIPTION_EN,
|
|
23
|
+
AGENT_DESCRIPTION_ZH,
|
|
24
|
+
BUGX_WORKER_DESCRIPTION,
|
|
25
|
+
BUGX_WORKER_DESCRIPTION_EN,
|
|
26
|
+
BUGX_WORKER_DESCRIPTION_ZH,
|
|
27
|
+
get_agent_description,
|
|
28
|
+
get_worker_description,
|
|
29
|
+
)
|
|
20
30
|
|
|
21
31
|
|
|
22
32
|
def _windows_drive_roots() -> tuple[Path, ...]:
|
|
@@ -83,55 +93,6 @@ def _running_zcode_markers() -> tuple[Path, ...]:
|
|
|
83
93
|
return tuple(markers)
|
|
84
94
|
|
|
85
95
|
|
|
86
|
-
# 宿主入口 frontmatter 的触发文案。description 是各宿主决定"何时自动
|
|
87
|
-
# 启用 BugX agent"的路由依据,必须跨宿主保持一致。支持中英双语自适应,
|
|
88
|
-
# 非 zh 语言一律回退为规范英文。
|
|
89
|
-
AGENT_DESCRIPTION_EN = (
|
|
90
|
-
"An autonomous agent dedicated to code review, vulnerability hunting, and automated bug fixing. "
|
|
91
|
-
"Built for deep investigations, BugX steps in when you are wrapping up a feature, opening a pull request, or hunting down an elusive bug. "
|
|
92
|
-
"It analyzes code logic, automatically writes test cases to uncover and reproduce hidden flaws, and delivers verified patches that resolve root causes. "
|
|
93
|
-
"Always safeguarding your code quality and security."
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
AGENT_DESCRIPTION_ZH = (
|
|
97
|
-
"专注于代码质量与安全的自主审查智能体。专为深层缺陷排查而生——在功能写完、提 PR 或排查疑难 Bug 时,"
|
|
98
|
-
"它能深入分析代码逻辑,自动编写测试用例,挖掘、复现Bug和漏洞,生成经过验证的修复补丁。随时为您的代码质量和代码安全把关。"
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
# 并发 worker 子智能体的路由描述。OpenCode v2 通过 ``subagent`` 的 agent ID
|
|
102
|
-
# ``bugx-worker`` 派发;描述用于让主 Agent 在子智能体目录中识别其职责;文案与
|
|
103
|
-
# core/bugx-worker.md 的 frontmatter 保持一致,支持中英双语自适应。
|
|
104
|
-
BUGX_WORKER_DESCRIPTION_ZH = (
|
|
105
|
-
"BugX 并发审查 Worker。由 BugX 主智能体并发调度,负责具体代码模块的深度审查、缺陷挖掘与可复现用例验证;"
|
|
106
|
-
"仅作为子智能体工作节点协同运行。"
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
BUGX_WORKER_DESCRIPTION_EN = (
|
|
110
|
-
"A concurrent audit worker dispatched in parallel by the primary BugX agent to inspect assigned modules, "
|
|
111
|
-
"hunt vulnerabilities, and verify defect reproduction as a collaborative subagent."
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
# 默认导出别名(维持向后兼容性,默认中文)
|
|
115
|
-
AGENT_DESCRIPTION = AGENT_DESCRIPTION_ZH
|
|
116
|
-
BUGX_WORKER_DESCRIPTION = BUGX_WORKER_DESCRIPTION_ZH
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
def get_agent_description(locale: str | None = None) -> str:
|
|
120
|
-
"""Return the localized host agent description (fallback to en-US)."""
|
|
121
|
-
loc = (locale or "").strip()
|
|
122
|
-
if loc.startswith("zh"):
|
|
123
|
-
return AGENT_DESCRIPTION_ZH
|
|
124
|
-
return AGENT_DESCRIPTION_EN
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
def get_worker_description(locale: str | None = None) -> str:
|
|
128
|
-
"""Return the localized concurrent worker description (fallback to en-US)."""
|
|
129
|
-
loc = (locale or "").strip()
|
|
130
|
-
if loc.startswith("zh"):
|
|
131
|
-
return BUGX_WORKER_DESCRIPTION_ZH
|
|
132
|
-
return BUGX_WORKER_DESCRIPTION_EN
|
|
133
|
-
|
|
134
|
-
|
|
135
96
|
# ZCode 并发 worker 子智能体的模板路径与历史项目级安装位置。
|
|
136
97
|
# 0.7.18 起 worker 不再写项目级入口,只做用户级注册(storageRoot/agents)
|
|
137
98
|
# 与插件镜像;该路径保留给无登记遗留清扫(清理旧版本写入的项目级副本)。
|
|
@@ -805,19 +766,19 @@ def workbuddy_cli_venv() -> Path | None:
|
|
|
805
766
|
|
|
806
767
|
|
|
807
768
|
def workbuddy_cli_venv_version(venv_path: Path | None = None) -> str | None:
|
|
808
|
-
"""快速探测 WorkBuddy 私有环境中的 bugx-
|
|
769
|
+
"""快速探测 WorkBuddy 私有环境中的 bugx-cli 版本,优先读 dist-info 免进程开销。"""
|
|
809
770
|
venv = venv_path or workbuddy_cli_venv()
|
|
810
771
|
if not venv:
|
|
811
772
|
return None
|
|
812
773
|
lib_dir = venv / ("Lib" if os.name == "nt" else "lib")
|
|
813
774
|
if lib_dir.is_dir():
|
|
814
775
|
for sp in lib_dir.glob("python*/site-packages"):
|
|
815
|
-
for dist in sp.glob("
|
|
816
|
-
match = re.search(r"
|
|
776
|
+
for dist in sp.glob("bugx_cli-*.dist-info"):
|
|
777
|
+
match = re.search(r"bugx_cli-([\d.]+)\.dist-info", dist.name)
|
|
817
778
|
if match:
|
|
818
779
|
return match.group(1)
|
|
819
|
-
for dist in (lib_dir / "site-packages").glob("
|
|
820
|
-
match = re.search(r"
|
|
780
|
+
for dist in (lib_dir / "site-packages").glob("bugx_cli-*.dist-info"):
|
|
781
|
+
match = re.search(r"bugx_cli-([\d.]+)\.dist-info", dist.name)
|
|
821
782
|
if match:
|
|
822
783
|
return match.group(1)
|
|
823
784
|
bin_dir = venv / ("Scripts" if os.name == "nt" else "bin")
|
|
@@ -1487,6 +1448,20 @@ class ZCodeAdapter(HostAdapter):
|
|
|
1487
1448
|
def _app_markers(self) -> tuple[Path, ...]:
|
|
1488
1449
|
return _zcode_app_markers()
|
|
1489
1450
|
|
|
1451
|
+
def _user_marker(self) -> bool:
|
|
1452
|
+
# F-RSI-20261118-009:ZCode Desktop 的 agent 注册是用户级全局的
|
|
1453
|
+
# (~/.zcode/agents/bugx.md),不是项目级 .zcode 目录——所有项目都
|
|
1454
|
+
# 能用。project_marker 检查 root/.zcode 对用户注册宿主永远 False。
|
|
1455
|
+
agents_dir = Path.home() / ".zcode" / "agents"
|
|
1456
|
+
return (agents_dir / "bugx.md").is_file()
|
|
1457
|
+
|
|
1458
|
+
def _project_marker(self, root: Path) -> bool:
|
|
1459
|
+
# ZCode 是用户级注册宿主:用户级 agents 已注册即视为宿主可用,
|
|
1460
|
+
# 项目级 .zcode 目录不是必要条件(ZCode Desktop 不按项目写入 .zcode)。
|
|
1461
|
+
if self._user_marker():
|
|
1462
|
+
return True
|
|
1463
|
+
return super()._project_marker(root)
|
|
1464
|
+
|
|
1490
1465
|
def render_required_entry(
|
|
1491
1466
|
self, relative_path: str, source: Path, *, locale: str | None = None,
|
|
1492
1467
|
) -> str | None:
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
统一管理所有受支持宿主组件声明,对外导出 HOST_COMPONENTS 清单与查找方法。
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
from
|
|
6
|
+
from ..infra.security import _find_repo_root
|
|
7
7
|
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
from typing import Any
|
|
@@ -281,12 +281,14 @@ def engine_worker_entry_dir(name: str) -> str:
|
|
|
281
281
|
|
|
282
282
|
|
|
283
283
|
#: ``bugx autonomous`` / ``bugx goal`` 的 ``--host`` 展示基线(顺序即 help 顺序)。
|
|
284
|
-
#:
|
|
285
|
-
#:
|
|
286
|
-
#:
|
|
287
|
-
#:
|
|
284
|
+
#: 成员都是**无 CLI 进程池执行器**的宿主:claude/codex/opencode/dsh 走原生 Task
|
|
285
|
+
#: 派发;pi 无原生 Task(``native_task=False``)但插件已声明
|
|
286
|
+
#: ``engine_run.autonomous_argv`` 无头自治通道(``pi --approve -p --mode json``),
|
|
287
|
+
#: 前台自治循环直接驱动。声明 ``worker_runtime.autonomous_cli`` 的插件(CLI
|
|
288
|
+
#: 进程池执行器)自动追加,不进本表。这不是第二份宿主事实:宿主身份仍在
|
|
289
|
+
#: 插件/``SUPPORTED_HOSTS``,本表只说「CLI 的 host 选项按什么顺序出现」。
|
|
288
290
|
AUTONOMOUS_HOST_BASELINE: tuple[str, ...] = (
|
|
289
|
-
"claude", "codex", "opencode", "dsh",
|
|
291
|
+
"claude", "codex", "opencode", "dsh", "pi",
|
|
290
292
|
)
|
|
291
293
|
|
|
292
294
|
|