bugx-cli 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +26 -29
  2. package/core/README.md +5 -3
  3. package/core/agent/agent_orchestrator.py +3 -0
  4. package/core/agent/agent_workspace.py +14 -2
  5. package/core/assets/bugx-wechat-group.png +0 -0
  6. package/core/assets/twitter_promo_art.jpg +0 -0
  7. package/core/assets/twitter_promo_card.svg +166 -0
  8. package/core/assets/twitter_promo_clean.jpg +0 -0
  9. package/core/assets/twitter_terminal_real.png +0 -0
  10. package/core/bugx.md +3 -3
  11. package/core/bugx_paths.py +10 -2
  12. package/core/bundled_docs/OVERVIEW.md +310 -0
  13. package/core/bundled_docs/README.md +10 -0
  14. package/core/bundled_docs/README_EN.md +278 -0
  15. package/core/bundled_docs/ai/01_AI_REFERENCE.md +833 -0
  16. package/core/bundled_docs/ai/02_AI_USAGE.md +161 -0
  17. package/core/bundled_docs/ai/03_AI_COMMANDS.md +322 -0
  18. package/core/bundled_docs/guides/01_USER_GUIDE.md +887 -0
  19. package/core/bundled_docs/guides/02_COMMANDS.md +935 -0
  20. package/core/bundled_docs/guides/03_TROUBLESHOOTING.md +763 -0
  21. package/core/bundled_docs/guides/04_CLOUD_AUTH_AND_SYNC_COOKBOOK.md +48 -0
  22. package/core/bundled_docs/guides/05_HOST_MATRIX_AND_DISPATCH.md +23 -0
  23. package/core/bundled_docs/guides/06_PROBES_AND_POC_COOKBOOK.md +49 -0
  24. package/core/bundled_docs/guides/07_LIFECYCLE_AND_RECOVERY_STATES.md +46 -0
  25. package/core/bundled_docs/guides/08_LESSONS_AND_PRIVACY_BOUNDARY.md +35 -0
  26. package/core/bundled_docs/hosts/bugx-claude_SKILL.md +326 -0
  27. package/core/bundled_docs/hosts/bugx-dsh_SKILL.md +229 -0
  28. package/core/bundled_docs/hosts/bugx-opencode_SKILL.md +129 -0
  29. package/core/bundled_docs/hosts/bugx-zcode_SKILL.md +459 -0
  30. package/core/bundled_docs/hosts/bugx_SKILL.md +118 -0
  31. package/core/bundled_docs/hosts/cline_bugx_SKILL.md +69 -0
  32. package/core/bundled_docs/hosts/platform_bugx_SKILL.md +50 -0
  33. package/core/bundled_docs/manifest.json +140 -0
  34. package/core/bundled_docs/reference/01_ENVIRONMENT_VARIABLES.md +421 -0
  35. package/core/bundled_docs/reference/04_REPOSITORY_TOPOLOGY.md +180 -0
  36. package/core/cli-help.txt +7 -3
  37. package/core/cloud_sync/cloud_client.py +81 -2
  38. package/core/cloud_sync/endpoint_router.py +22 -9
  39. package/core/cloud_sync/issue_uploader.py +297 -0
  40. package/core/cloud_sync/sensitive_filter.py +77 -7
  41. package/core/contracts/AGENT_GUIDE.md +3 -9
  42. package/core/contracts/README.md +1 -1
  43. package/core/contracts/bugx-opencode.md +1 -1
  44. package/core/contracts/bugx-runtime-contract.md +10 -20
  45. package/core/contracts/bugx-worker.md +1 -1
  46. package/core/engine-integrity.json +267 -111
  47. package/core/host_acp/antigravity.py +153 -0
  48. package/core/host_acp/kimi.py +175 -0
  49. package/core/host_acp/minimax.py +28 -0
  50. package/core/host_runtime/adapters.py +5 -1
  51. package/core/host_runtime/antigravity.py +162 -0
  52. package/core/host_runtime/host_bootstrap.py +18 -7
  53. package/core/host_runtime/host_evaluators.py +4 -4
  54. package/core/host_runtime/host_registry.py +25 -4
  55. package/core/host_runtime/mcp_process_tracker.py +30 -3
  56. package/core/host_runtime/mcp_registry_gate.py +34 -11
  57. package/core/hosts/antigravity.py +115 -0
  58. package/core/hosts/codex.py +3 -0
  59. package/core/hosts/dsh.py +43 -24
  60. package/core/hosts/kimi.py +293 -0
  61. package/core/hosts/minimax.py +249 -0
  62. package/core/hosts/zcode.py +5 -0
  63. package/core/i18n.py +94 -5
  64. package/core/infra/README.md +1 -1
  65. package/core/infra/build_info.py +30 -5
  66. package/core/launch_phases/README.md +2 -2
  67. package/core/launch_phases/startup_version_gate.py +2 -2
  68. package/core/launch_phases/supervisor_bridge.py +16 -23
  69. package/core/launch_phases/supervisor_degraded.py +7 -5
  70. package/core/ledger/README.md +1 -1
  71. package/core/locales/en-US.json +3 -3
  72. package/core/locales/zh-CN.json +3 -3
  73. package/core/mcp_runtime_support/environment.py +6 -1
  74. package/core/metadata.txt +2 -2
  75. package/core/planning/README.md +1 -1
  76. package/core/planning/prompt_harness.py +2 -2
  77. package/core/probes/codebase_memory_probe.py +43 -24
  78. package/core/probes/probe_registry.py +10 -7
  79. package/core/prompts/command_routing_en.md +6 -5
  80. package/core/prompts/command_routing_zh.md +6 -5
  81. package/core/repair/rsi_rounds.py +3 -0
  82. package/core/repair/self_heal.py +160 -6
  83. package/core/retrieval/README.md +1 -1
  84. package/core/runtime/README.md +1 -1
  85. package/core/runtime/scenario_eval.py +5 -1
  86. package/core/runtime/setup_ui_env.py +4 -7
  87. package/core/runtime/tool_install_targets.py +12 -2
  88. package/core/skills/README.md +4 -2
  89. package/core/skills/bugx_docs_cloud_sync.py +658 -0
  90. package/core/skills/bugx_docs_mcp_server.py +966 -140
  91. package/core/supervisor/README.md +1 -1
  92. package/core/supervisor/cli.py +2 -2
  93. package/core/supervisor/worker_execution.py +16 -3
  94. package/core/webui/docs_session_service.py +40 -2
  95. package/core/webui/mcp_inspector.py +12 -6
  96. package/core/webui/static/index.html +51 -3
  97. package/core/webui/static/manifest.webmanifest +1 -1
  98. package/core/webui/static/project-settings.js +18 -3
  99. package/core/webui/static/robots.txt +36 -0
  100. package/core/webui/static/sitemap.xml +15 -0
  101. package/docs/07_distribution/01_README_NPM.md +26 -29
  102. package/ecosystem/integrations/cline/skills/bugx/SKILL.md +46 -46
  103. package/ecosystem/integrations/dsh/agents/bugx.md +2 -1
  104. package/ecosystem/integrations/dsh/dsh-patch.yml +2 -2
  105. package/ecosystem/integrations/dsh/mcp/package.json +1 -1
  106. package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +6 -6
  107. package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +1 -1
  108. package/ecosystem/integrations/dsh/ui/package.json +1 -1
  109. package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +2 -2
  110. package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
  111. package/ecosystem/integrations/pi/skills/bugx/SKILL.md +6 -6
  112. package/ecosystem/integrations/qoder/CONNECTORS.md +11 -23
  113. package/ecosystem/integrations/qoder/connector-meta.json +9 -9
  114. package/ecosystem/integrations/workbuddy/connector-meta.json +9 -9
  115. package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +8 -7
  116. package/ecosystem/plugins/bugx/.claude-plugin/marketplace.json +2 -2
  117. package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +2 -2
  118. package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +4 -4
  119. package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +2 -2
  120. package/ecosystem/plugins/bugx/agents/bugx-worker.md +14 -18
  121. package/ecosystem/plugins/bugx/agents/bugx.md +45 -49
  122. package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +8 -8
  123. package/ecosystem/plugins/bugx/skills/bugx-claude/SKILL.md +1 -1
  124. package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +1 -1
  125. package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +1 -1
  126. package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +3 -3
  127. package/interfaces/bin/bugx.js +2 -0
  128. package/interfaces/cli/bugx_cli/__init__.py +2 -2
  129. package/interfaces/cli/bugx_cli/cli.py +153 -8
  130. package/interfaces/cli/bugx_cli/commands/agent.py +568 -136
  131. package/interfaces/cli/bugx_cli/commands/cloud.py +42 -1
  132. package/interfaces/cli/bugx_cli/commands/doctor.py +668 -223
  133. package/interfaces/cli/bugx_cli/commands/guide.py +143 -0
  134. package/interfaces/cli/bugx_cli/commands/issue.py +262 -0
  135. package/interfaces/cli/bugx_cli/commands/lifecycle.py +99 -62
  136. package/interfaces/cli/bugx_cli/commands/plugin.py +301 -60
  137. package/interfaces/cli/bugx_cli/commands/plugin_antigravity.py +350 -0
  138. package/interfaces/cli/bugx_cli/commands/plugin_claude.py +27 -13
  139. package/interfaces/cli/bugx_cli/commands/plugin_kimi.py +440 -0
  140. package/interfaces/cli/bugx_cli/commands/plugin_minimax.py +522 -0
  141. package/interfaces/cli/bugx_cli/commands/plugin_qoder.py +3 -4
  142. package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +4 -5
  143. package/interfaces/cli/bugx_cli/commands/system.py +75 -5
  144. package/interfaces/cli/bugx_cli/common.py +135 -15
  145. package/interfaces/cli/bugx_cli/host_adapters.py +190 -7
  146. package/interfaces/cli/bugx_cli/hosts/registry.py +6 -3
  147. package/interfaces/cli/bugx_cli/hosts/template_engine.py +31 -11
  148. package/interfaces/cli/bugx_cli/infra/__init__.py +4 -0
  149. package/interfaces/cli/bugx_cli/infra/ai_advisor.py +14 -12
  150. package/interfaces/cli/bugx_cli/infra/engine_installer.py +76 -10
  151. package/interfaces/cli/bugx_cli/infra/host_sync.py +66 -1
  152. package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +242 -52
  153. package/package.json +38 -13
  154. package/pyproject.toml +57 -13
  155. package/scripts/sync-version.mjs +1 -1
  156. package/skills/README.md +24 -0
  157. package/skills/platform/bugx/SKILL.md +50 -0
@@ -22,6 +22,7 @@ from ..common import _close_bugx_logging
22
22
  from ..infra.engine_installer import refresh_i18n_after_engine_swap
23
23
  from ..common import *
24
24
  from ..hosts.registry import (
25
+ QODER_PROJECT_MCP_PATHS,
25
26
  engine_host_cli_hook,
26
27
  engine_host_label,
27
28
  engine_host_plugins,
@@ -53,6 +54,7 @@ from ..host_adapters import (
53
54
  HostAdapter,
54
55
  HOST_NAME_CLAUDE,
55
56
  HOST_NAME_FUNIDE,
57
+ HOST_NAME_KIMI,
56
58
  HOST_NAME_QODER,
57
59
  HOST_NAME_ZCODE,
58
60
  )
@@ -60,6 +62,7 @@ from .plugin import (
60
62
  _chatgpt_marketplace,
61
63
  _ensure_chatgpt_plugin,
62
64
  _ensure_zcode_plugin,
65
+ _qoder_mcp_entry_is_current,
63
66
  _sweep_legacy_skill_entry,
64
67
  _sweep_legacy_zcode_project_entries,
65
68
  _prompt_for_hosts,
@@ -103,13 +106,18 @@ class _CliProgress:
103
106
  percent = max(0, min(100, percent))
104
107
  filled = self._WIDTH * percent // 100
105
108
  line = f"[bugx] 进度 [{('=' * filled).ljust(self._WIDTH, '-')}] {percent:3d}% {label}"
106
- sys.stderr.write("\r" + line)
109
+ cols = sum(2 if ord(ch) > 127 else 1 for ch in line)
110
+ prev = int(getattr(self, "_last_cols", 0))
111
+ pad = " " * max(0, prev - cols)
112
+ self._last_cols = cols
113
+ sys.stderr.write("\r" + line + pad)
107
114
  sys.stderr.flush()
108
115
 
109
116
  def finish(self, label: str = "完成") -> None:
110
117
  if not self.enabled:
111
118
  return
112
119
  self.update(100, label)
120
+ self._last_cols = 0
113
121
  sys.stderr.write("\n")
114
122
  sys.stderr.flush()
115
123
 
@@ -217,7 +225,6 @@ _AGENT_INSTALL_SNAPSHOT_FILES = (
217
225
  ".agents/plugins/marketplace.json",
218
226
  ".qoder/agents/bugx.md",
219
227
  ".qoder/agents/bugx-worker.md",
220
- ".qoder/mcp.json",
221
228
  ".github/agents/bugx.agent.md",
222
229
  ".trea/agents/bugx.md",
223
230
  ".trea/mcp.json",
@@ -436,6 +443,8 @@ def _agent_install_snapshot(
436
443
  """
437
444
  staging = Path(tempfile.mkdtemp(prefix="bugx-install-transaction-")).resolve()
438
445
  existed: dict[str, bool] = {}
446
+ if _is_global_home_scope(root):
447
+ return staging, existed
439
448
  try:
440
449
  for relative in _agent_install_surfaces(selected_adapters):
441
450
  target = root / relative
@@ -688,6 +697,8 @@ def _remove_install_snapshot_tree(path: Path) -> None:
688
697
  def _restore_agent_install_snapshot(
689
698
  root: Path, staging: Path, existed: dict[str, bool],
690
699
  ) -> None:
700
+ if _is_global_home_scope(root) or not existed:
701
+ return
691
702
  manifest_path = staging / _AGENT_INSTALL_SNAPSHOT_MANIFEST
692
703
  if manifest_path.is_file():
693
704
  payload = json.loads(manifest_path.read_text(encoding="utf-8"))
@@ -788,7 +799,8 @@ def _select_install_adapters(
788
799
  if args.non_interactive:
789
800
  raise CliError(_i18n_exc(
790
801
  "agent.non_interactive_agent_required",
791
- "非交互安装必须显式提供 --agent opencode/dsh/codex/cline/claude/zcode/workbuddy/pi/chatgpt/qoder/trea/funide",
802
+ "非交互安装必须显式提供 --agent "
803
+ + "/".join(adapter.name for adapter in HOST_ADAPTERS),
792
804
  ))
793
805
  if not sys.stdin.isatty():
794
806
  raise CliError(_i18n_exc(
@@ -836,6 +848,180 @@ def _select_install_adapters(
836
848
  return tuple(selected)
837
849
 
838
850
 
851
+ def _sync_global_pi_skill_global_mode(root: Path, *, locale: str | None = None) -> None:
852
+ """Install user-level ~/.agents/skills/bugx and ~/.pi skill links without touching root/.pi."""
853
+ skill_src = pi_skill_root() / "SKILL.md"
854
+ if not skill_src.is_file():
855
+ return
856
+ content = add_locale_marker(skill_src.read_text(encoding="utf-8"), locale)
857
+ home = Path.home().resolve()
858
+ agents_skill_parent = (home / ".agents" / "skills").resolve(strict=False)
859
+ if not agents_skill_parent.is_relative_to(home):
860
+ raise CliError(_i18n_exc("agent.pi_global_skill_escaped_user", f"Pi 全局 Skill 目录越出用户目录:{agents_skill_parent}", path=agents_skill_parent))
861
+ _assert_no_symlink_components(agents_skill_parent)
862
+ agents_skill_dir = agents_skill_parent / "bugx"
863
+ _assert_no_symlink_components(agents_skill_dir)
864
+ agents_skill_dir.mkdir(parents=True, exist_ok=True)
865
+ target = agents_skill_dir / "SKILL.md"
866
+ _tx_stage_global(target)
867
+ _atomic_write_global_file_tx(target, content.encode("utf-8"))
868
+ for p_dir in (home / ".pi" / "skills" / "bugx", home / ".pi" / "agent" / "skills" / "bugx"):
869
+ _assert_no_symlink_components(p_dir.parent)
870
+ p_dir.parent.mkdir(parents=True, exist_ok=True)
871
+ if p_dir.is_symlink() or p_dir.exists():
872
+ if not p_dir.is_symlink():
873
+ # Only update inside already-owned file/dir if needed; skip foreign user directories
874
+ existing = p_dir / "SKILL.md"
875
+ if existing.is_file():
876
+ try:
877
+ _atomic_write_global_file_tx(existing, content.encode("utf-8"))
878
+ except OSError:
879
+ pass
880
+ continue
881
+ _atomic_link_or_copy(agents_skill_dir, p_dir, directory=True)
882
+
883
+
884
+ def _finish_global_home_install(
885
+ args: argparse.Namespace,
886
+ *,
887
+ root: Path,
888
+ source: Path,
889
+ selected: tuple[object, ...],
890
+ engine_copied: int,
891
+ engine_skipped: int,
892
+ deployment_locale: str,
893
+ cbm_detail: str,
894
+ ts_detail: str,
895
+ progress: _CliProgress | None = None,
896
+ ) -> int:
897
+ """Complete a User-Global Home Mode (`~`) install without polluting home with project files."""
898
+ del args.force
899
+ global_k = (_global_bugx_dir() / "knowledge").resolve()
900
+ override = os.environ.get("BUGX_GLOBAL_KNOWLEDGE_ROOT")
901
+ if override:
902
+ global_k = Path(override).expanduser().resolve()
903
+ if not (global_k / "global.sqlite3").is_file():
904
+ from .plugin import _bootstrap_global_knowledge
905
+
906
+ _bootstrap_global_knowledge(root, source)
907
+
908
+ selected_names = {str(getattr(adapter, "name", "")) for adapter in selected}
909
+ user_hosts_done: list[str] = []
910
+ project_only_hosts: list[str] = []
911
+ dsh_ui_plugin: dict[str, object] | None = None
912
+ dsh_patch_status: str | None = None
913
+ user_agents_by_host: dict[str, dict[str, object]] = {}
914
+ host_mcp_configs: dict[str, dict[str, object]] = {}
915
+ opencode_user_skill: dict[str, object] | None = None
916
+ workbuddy_user_skill: dict[str, object] | None = None
917
+ workbuddy_custom_expert: dict[str, object] | None = None
918
+
919
+ if progress is not None:
920
+ progress.update(70, "正在装配用户级宿主资产")
921
+
922
+ for adapter in selected:
923
+ name = str(adapter.name)
924
+ if adapter.supports(CAP_PROJECT_PATCH_OVERLAY):
925
+ dsh_patch_status, dsh_ui_plugin = _ensure_dsh_patch(root)
926
+ user_hosts_done.append(name)
927
+ if adapter.supports(CAP_NATIVE_MCP_CONFIG) and name == HOST_NAME_ZCODE:
928
+ item_status, path, _backup, _created = write_host_mcp_config(root, name)
929
+ host_mcp_configs[name] = {
930
+ "path": str(path),
931
+ "status": item_status,
932
+ "session_restart_required": item_status != "unchanged",
933
+ }
934
+ if adapter.supports(CAP_USER_AGENT_REGISTRATION):
935
+ res = adapter.ensure_user_agents(root, source, locale=deployment_locale)
936
+ if isinstance(res, dict):
937
+ user_agents_by_host[name] = res
938
+ if name == HOST_NAME_ZCODE:
939
+ from .plugin_zcode import (
940
+ _upsert_zcode_plugin_dirs,
941
+ _write_zcode_global_plugin,
942
+ )
943
+ _write_zcode_global_plugin(root, source, locale=deployment_locale)
944
+ _upsert_zcode_plugin_dirs(register=None, remove=False)
945
+ user_skill = _ensure_zcode_user_skill(root, source)
946
+ if name in user_agents_by_host:
947
+ user_agents_by_host[name]["user_skill"] = user_skill
948
+ if name not in user_hosts_done:
949
+ user_hosts_done.append(name)
950
+ if adapter.supports(CAP_GLOBAL_AGENT_LINK):
951
+ _register_global_opencode_agent(root)
952
+ opencode_user_skill = _ensure_opencode_user_skill(
953
+ root, source, backup_label=name,
954
+ )
955
+ if name not in user_hosts_done:
956
+ user_hosts_done.append(name)
957
+ if adapter.supports(CAP_GLOBAL_SKILL_LINK):
958
+ _sync_global_pi_skill_global_mode(root, locale=deployment_locale)
959
+ if name not in user_hosts_done:
960
+ user_hosts_done.append(name)
961
+ if adapter.supports(CAP_USER_LEVEL_ARTIFACT):
962
+ wb_content = adapter.render(global_engine_root() / "bugx.md", locale=deployment_locale)
963
+ workbuddy_user_skill = _ensure_workbuddy_user_skill(root, wb_content)
964
+ workbuddy_custom_expert = _ensure_workbuddy_custom_expert(root, wb_content)
965
+ for cfg_root in _workbuddy_config_roots():
966
+ if cfg_root != workbuddy_user_skill_root():
967
+ _ensure_workbuddy_custom_expert(root, wb_content, config_root=cfg_root)
968
+ if name not in user_hosts_done:
969
+ user_hosts_done.append(name)
970
+
971
+ if adapter.supports(CAP_PROJECT_MCP_CONFIG) or (
972
+ adapter.supports(CAP_NATIVE_MCP_CONFIG) and name not in {HOST_NAME_ZCODE}
973
+ ) or adapter.entry_mode == ENTRY_PLUGIN_CATALOG or name in {"codex", "cline", "trea", "claude", "qoder", "funide", "workbuddy", "pi"}:
974
+ project_only_hosts.append(name)
975
+
976
+ if progress is not None:
977
+ progress.finish("用户全局安装完成")
978
+ mcp_recommendations = _mcp_recommendations(root, installed_hosts=selected_names)
979
+ payload = {
980
+ "mode": "global",
981
+ "global_scope": True,
982
+ "root": str(root),
983
+ "shared_engine": str(global_engine_root()),
984
+ "shared_copied": engine_copied,
985
+ "shared_skipped": engine_skipped,
986
+ "required_tools": {
987
+ "codebase-memory-mcp": cbm_detail,
988
+ "tree-sitter-language-pack": ts_detail,
989
+ },
990
+ "user_level_hosts": sorted(set(user_hosts_done)),
991
+ "project_only_hosts": sorted(set(project_only_hosts)),
992
+ "dsh_patch": dsh_patch_status,
993
+ "dsh_ui_plugin": dsh_ui_plugin,
994
+ "user_agents_by_host": user_agents_by_host,
995
+ "host_mcp_configs": host_mcp_configs,
996
+ "opencode_user_skill": opencode_user_skill,
997
+ "workbuddy_user_skill": workbuddy_user_skill,
998
+ "workbuddy_custom_expert": workbuddy_custom_expert,
999
+ "mcp_recommendations": mcp_recommendations,
1000
+ "status": "installed",
1001
+ "ready": True,
1002
+ }
1003
+ if getattr(args, "json", False):
1004
+ print(json.dumps(payload, ensure_ascii=False, indent=2, default=_json_default))
1005
+ else:
1006
+ print("[bugx] ✓ 用户全局模式安装完成(未在主目录 ~ 创建项目 .bugx/manifest.json 或项目入口)")
1007
+ print(f" 共享引擎:{global_engine_root()}(复制 {engine_copied},未变更跳过 {engine_skipped})")
1008
+ print(f" 全局知识库:{global_k}")
1009
+ print(f" 必需核心工具:codebase-memory-mcp ({cbm_detail});tree-sitter ({ts_detail})")
1010
+ if user_hosts_done:
1011
+ print(f" 用户级宿主资产:{', '.join(sorted(set(user_hosts_done)))}")
1012
+ if dsh_ui_plugin is not None:
1013
+ detail_ui = str(dsh_ui_plugin.get("detail") or dsh_ui_plugin.get("status") or "")
1014
+ print(f" DSH UI 插件:{dsh_ui_plugin.get('root')}({detail_ui})")
1015
+ if project_only_hosts:
1016
+ print(
1017
+ " 提示:以下宿主需绑定具体工作区配置(当前仅完成全局层装配,未写入主目录 ~):"
1018
+ + ", ".join(sorted(set(project_only_hosts)))
1019
+ )
1020
+ print(" 进入具体项目目录后运行 `bugx install`(或 `bugx install --root <PROJECT>`)完成项目绑定。")
1021
+ _print_mcp_recommendations(mcp_recommendations)
1022
+ return 0
1023
+
1024
+
839
1025
  def _command_agent_impl(
840
1026
  args: argparse.Namespace,
841
1027
  *,
@@ -877,15 +1063,17 @@ def _command_agent_impl(
877
1063
  # Validate an existing host manifest before any resource or runtime writes;
878
1064
  # a corrupt manifest must never cause a partial installation and then fail.
879
1065
  existing_record = root / ".bugx" / "hosts.json"
880
- if existing_record.exists() or existing_record.is_symlink():
1066
+ is_home_scope = _is_global_home_scope(root)
1067
+ if not is_home_scope and (existing_record.exists() or existing_record.is_symlink()):
881
1068
  _merge_host_records(existing_record, [])
882
1069
 
883
1070
  # Validate host catalogs or prerequisites before shared runtime writes so
884
1071
  # an invalid or conflicting catalog cannot leave a partial install.
885
- for adapter in selected:
886
- adapter.pre_validate(root)
887
- if any(adapter.supports(CAP_PROJECT_MCP_CONFIG) for adapter in selected):
888
- _preflight_opencode_mcp_config(root)
1072
+ if not is_home_scope:
1073
+ for adapter in selected:
1074
+ adapter.pre_validate(root)
1075
+ if any(adapter.supports(CAP_PROJECT_MCP_CONFIG) for adapter in selected):
1076
+ _preflight_opencode_mcp_config(root)
889
1077
  if progress is not None:
890
1078
  progress.update(15, "已完成配置校验")
891
1079
 
@@ -893,7 +1081,10 @@ def _command_agent_impl(
893
1081
  source = asset_root()
894
1082
  # DOC-004 Layout 2:项目不再承载可执行 core。旧项目必须显式选择
895
1083
  # 破坏性迁移;迁移会先转移运行态/项目数据,再把旧 core 移出活动布局。
896
- removed_legacy_core = _require_global_only_layout(root)
1084
+ if not is_home_scope:
1085
+ removed_legacy_core = _require_global_only_layout(root)
1086
+ else:
1087
+ removed_legacy_core = False
897
1088
  if progress is not None:
898
1089
  progress.update(20, "正在安装共享引擎")
899
1090
  engine = global_engine_root()
@@ -923,6 +1114,38 @@ def _command_agent_impl(
923
1114
  )
924
1115
  _ensure_global_cli_symlinks()
925
1116
 
1117
+ if progress is not None:
1118
+ progress.update(45, "校验并装配必需核心依赖(codebase-memory / tree-sitter)")
1119
+ _ensure_core_importable()
1120
+ from core.repair.self_heal import (
1121
+ ensure_codebase_memory_ready,
1122
+ ensure_tree_sitter_ready,
1123
+ )
1124
+ cbm_ok, cbm_detail = ensure_codebase_memory_ready(root)
1125
+ if not cbm_ok:
1126
+ raise CliError(
1127
+ f"必需核心依赖 codebase-memory-mcp 安装或校验失败(不可降级放行):{cbm_detail}"
1128
+ )
1129
+ ts_ok, ts_detail = ensure_tree_sitter_ready()
1130
+ if not ts_ok:
1131
+ raise CliError(
1132
+ f"必需核心依赖 tree-sitter-language-pack 安装或校验失败(不可降级放行):{ts_detail}"
1133
+ )
1134
+
1135
+ if is_home_scope:
1136
+ return _finish_global_home_install(
1137
+ args,
1138
+ root=root,
1139
+ source=source,
1140
+ selected=selected,
1141
+ engine_copied=copied,
1142
+ engine_skipped=skipped,
1143
+ deployment_locale=deployment_locale,
1144
+ cbm_detail=cbm_detail,
1145
+ ts_detail=ts_detail,
1146
+ progress=progress,
1147
+ )
1148
+
926
1149
  _layout_module(root).initialize(root, bugx_version=__version__)
927
1150
  _ensure_project_readme(root, source)
928
1151
  # The common runtime is intentionally installed once even when the selected
@@ -930,21 +1153,29 @@ def _command_agent_impl(
930
1153
  _initialize_lesson_ledger(root, source)
931
1154
  _initialize_project_knowledge_snapshots(root, source)
932
1155
  _initialize_life_state(root)
1156
+ from .lifecycle import _ensure_project_startup_todo
1157
+ _ensure_project_startup_todo(root)
933
1158
  if progress is not None:
934
1159
  progress.update(60, "项目运行态初始化完成")
935
1160
  if removed_legacy_core:
936
1161
  print(f"[bugx] 已直接删除旧项目引擎入口:{removed_legacy_core}")
937
1162
  selected_mcp_names = targeted_mcp_names(root)
938
- optional_mcp_names = selected_mcp_names & {"playwright", "postmcp"}
939
- provisioned_optional_mcps = provision_targeted_mcp_runtime(root, optional_mcp_names)
1163
+ # 可选 MCP 能力(playwright/postmcp 等)延迟至实际项目审计 pre 阶段由 AI 与用户决定启用,
1164
+ # 不在 install 阶段触发耗时联网装配。
1165
+ provisioned_optional_mcps: set[str] = set()
940
1166
  opencode_config_status: str | None = None
941
1167
  opencode_config_backup: Path | None = None
942
1168
  host_mcp_configs: dict[str, dict[str, object]] = {}
943
1169
  dsh_patch_status: str | None = None
944
1170
  dsh_ui_plugin: dict[str, object] | None = None
1171
+ docs_transport = getattr(args, "docs_transport", None)
1172
+ docs_remote_url = getattr(args, "docs_remote_url", None)
945
1173
  if any(adapter.supports(CAP_PROJECT_MCP_CONFIG) for adapter in selected):
946
1174
  opencode_config_status, opencode_config_backup = _ensure_opencode_config(
947
- root, selected=selected_mcp_names,
1175
+ root,
1176
+ selected=selected_mcp_names,
1177
+ docs_transport=docs_transport,
1178
+ docs_remote_url=docs_remote_url,
948
1179
  )
949
1180
  if any(adapter.supports(CAP_PROJECT_PATCH_OVERLAY) for adapter in selected):
950
1181
  dsh_patch_status, dsh_ui_plugin = _ensure_dsh_patch(root)
@@ -1197,7 +1428,11 @@ def _command_agent_impl(
1197
1428
  )
1198
1429
  for config_host in config_hosts:
1199
1430
  item_status, path, backup, created = write_host_mcp_config(
1200
- root, config_host, optional_names=provisioned_optional_mcps,
1431
+ root,
1432
+ config_host,
1433
+ optional_names=provisioned_optional_mcps,
1434
+ docs_transport=docs_transport,
1435
+ docs_remote_url=docs_remote_url,
1201
1436
  )
1202
1437
  config_paths.append(str(path))
1203
1438
  if item_status != "unchanged":
@@ -1223,40 +1458,44 @@ def _command_agent_impl(
1223
1458
  "to": str(root),
1224
1459
  }
1225
1460
  host_mcp_configs[adapter.name] = host_info
1226
- if adapter.supports(CAP_USER_AGENT_REGISTRATION):
1227
- # User-level agent registrations share the install transaction;
1228
- # MCP files remain scoped to this project.
1229
- registered_user_agents = adapter.ensure_user_agents(
1230
- root, source, locale=deployment_locale,
1461
+ # User-level registrations are independent of project MCP writing.
1462
+ # MiniMax Plugin V1 has no project MCP container: its package owns both
1463
+ # the Agent manifests and servers.mcp.json under the user data root.
1464
+ for adapter in selected:
1465
+ if not adapter.supports(CAP_USER_AGENT_REGISTRATION):
1466
+ continue
1467
+ registered_user_agents = adapter.ensure_user_agents(
1468
+ root, source, locale=deployment_locale,
1469
+ )
1470
+ if registered_user_agents is None:
1471
+ raise CliError(
1472
+ f"{adapter.label} 声明支持用户级注册,但注册器没有返回结果;"
1473
+ "已阻断安装,避免报告成功但插件未生效。"
1231
1474
  )
1232
- if registered_user_agents is not None:
1233
- user_agents_by_host[adapter.name] = registered_user_agents
1234
- if adapter.name == HOST_NAME_ZCODE:
1235
- # ZCode 专属:用户级使用手册 Skill 与 agents 同事务部署
1236
- # (全局层,跨项目可见;内容随 wheel 版本演进)。
1237
- zcode_user_skill = _ensure_zcode_user_skill(root, source)
1238
- user_agents_by_host[adapter.name]["user_skill"] = (
1239
- zcode_user_skill
1240
- )
1241
- for item in zcode_user_skill["written"]:
1242
- if item["status"] == "unchanged":
1243
- continue
1244
- host_mcp_changes.append((
1245
- Path(str(item["path"])),
1246
- Path(str(item["backup"])) if item["backup"] else None,
1247
- bool(item["created"]),
1248
- ))
1249
- host_backups.extend(zcode_user_skill["backups"])
1250
- for item in registered_user_agents["written"]:
1251
-
1252
- if item["status"] == "unchanged":
1253
- continue
1254
- host_mcp_changes.append((
1255
- Path(str(item["path"])),
1256
- Path(str(item["backup"])) if item["backup"] else None,
1257
- bool(item["created"]),
1258
- ))
1259
- host_backups.extend(registered_user_agents["backups"])
1475
+ user_agents_by_host[adapter.name] = registered_user_agents
1476
+ if adapter.name == HOST_NAME_ZCODE:
1477
+ # ZCode 专属:用户级使用手册 Skill 与 agents 同事务部署
1478
+ # (全局层,跨项目可见;内容随 wheel 版本演进)。
1479
+ zcode_user_skill = _ensure_zcode_user_skill(root, source)
1480
+ user_agents_by_host[adapter.name]["user_skill"] = zcode_user_skill
1481
+ for item in zcode_user_skill["written"]:
1482
+ if item["status"] == "unchanged":
1483
+ continue
1484
+ host_mcp_changes.append((
1485
+ Path(str(item["path"])),
1486
+ Path(str(item["backup"])) if item["backup"] else None,
1487
+ bool(item["created"]),
1488
+ ))
1489
+ host_backups.extend(zcode_user_skill["backups"])
1490
+ for item in registered_user_agents["written"]:
1491
+ if item["status"] == "unchanged":
1492
+ continue
1493
+ host_mcp_changes.append((
1494
+ Path(str(item["path"])),
1495
+ Path(str(item["backup"])) if item["backup"] else None,
1496
+ bool(item["created"]),
1497
+ ))
1498
+ host_backups.extend(registered_user_agents["backups"])
1260
1499
  for adapter in selected:
1261
1500
  if adapter.supports(CAP_GLOBAL_AGENT_LINK):
1262
1501
  # global-agent-link 宿主(现仅 opencode):用户级使用手册 Skill
@@ -1396,7 +1635,7 @@ def _command_agent_impl(
1396
1635
  if progress is not None:
1397
1636
  progress.update(98, "安装记录已写入")
1398
1637
  progress.finish()
1399
- mcp_recommendations = _mcp_recommendations(root)
1638
+ mcp_recommendations = _mcp_recommendations(root, installed_hosts=selected_names)
1400
1639
  payload = {
1401
1640
  "status": "INSTALLED", "root": str(root),
1402
1641
  "hosts": installed, "shared_copied": copied, "shared_skipped": skipped,
@@ -1475,11 +1714,11 @@ def _command_agent_impl(
1475
1714
  status = str(info["status"])
1476
1715
  path = str(info["path"])
1477
1716
  if status == "created":
1478
- print(f" {host_name} MCP 配置:已创建 {path}(host/worker 双通道)")
1717
+ print(f" {host_name} MCP 配置:已创建 {path}(host/worker 双通道,需重启宿主会话生效)")
1479
1718
  elif status == "unchanged":
1480
1719
  print(f" {host_name} MCP 配置:已是最新双通道配置,保持不变({path})")
1481
1720
  else:
1482
- print(f" {host_name} MCP 配置:已备份并{status}双通道({path})")
1721
+ print(f" {host_name} MCP 配置:已备份并{status}双通道({path},需重启宿主会话生效)")
1483
1722
  switched = info.get("root_switch")
1484
1723
  if isinstance(switched, dict):
1485
1724
  print(
@@ -1585,6 +1824,23 @@ def _command_agent_impl(
1585
1824
  f" Qoder 用户级资产:已是最新,保持不变"
1586
1825
  f"({qoder_user_agents['dir']})"
1587
1826
  )
1827
+ if (kimi_user_agents := user_agents_by_host.get(HOST_NAME_KIMI)) is not None:
1828
+ reported_user_agents.add(HOST_NAME_KIMI)
1829
+ changed = [
1830
+ item for item in kimi_user_agents["written"]
1831
+ if item["status"] != "unchanged"
1832
+ ]
1833
+ if changed:
1834
+ names = "、".join(Path(str(item["path"])).name for item in changed)
1835
+ print(
1836
+ f" Kimi 桌面端插件与徽标:已配置 {names}"
1837
+ f"({kimi_user_agents['dir']},免点击直接启用)"
1838
+ )
1839
+ else:
1840
+ print(
1841
+ f" Kimi 桌面端插件:已是最新并处于启用状态"
1842
+ f"({kimi_user_agents['dir']})"
1843
+ )
1588
1844
  # 其余宿主的用户级注册结果统一汇报(标签来自插件/组件表,不写宿主名)。
1589
1845
  for host_name, payload in user_agents_by_host.items():
1590
1846
  if host_name in reported_user_agents:
@@ -1650,7 +1906,22 @@ def _command_agent_impl(
1650
1906
  f" DSH UI 插件:已暂存 {dsh_ui_plugin['root']}({dsh_ui_plugin['detail']})"
1651
1907
  )
1652
1908
  print(" DSH Web 启动:dsh web(按当前 Session 工作区自动绑定;未选目录会明确提示)")
1909
+ mcp_restart_targets: list[str] = []
1910
+ for host_name, info in host_mcp_configs.items():
1911
+ if info.get("session_restart_required"):
1912
+ mcp_restart_targets.append(f"{host_name}: {info.get('path')}")
1653
1913
  if opencode_config_status in {"created", "merged"}:
1914
+ mcp_restart_targets.append(f"OpenCode: {CONFIG_NAME}")
1915
+
1916
+ if mcp_restart_targets:
1917
+ print("\n ========================================================")
1918
+ print(" ⚠【必须强制重启宿主会话】")
1919
+ print(" 项目 MCP 配置已新建/更新,宿主进程不支持动态热加载:")
1920
+ for target_desc in mcp_restart_targets:
1921
+ print(f" - {target_desc}")
1922
+ print(" 请务必执行:【重载窗口 / 重启宿主会话】后再启动 BugX!")
1923
+ print(" ========================================================\n")
1924
+ elif opencode_config_status in {"created", "merged"}:
1654
1925
  print(" ⚠ OpenCode MCP 配置已变化;现有会话通常不会热加载。启动 BugX 时会先主动探活,"
1655
1926
  "探活未命中时再提示重启 OpenCode 会话")
1656
1927
  _print_mcp_recommendations(mcp_recommendations)
@@ -1899,6 +2170,17 @@ def _deploy_dsh_ui_plugin() -> dict[str, object]:
1899
2170
  "status": "staged",
1900
2171
  "detail": "未发现可管理的 DSH web profile,保留包供 dsh plugin add 使用",
1901
2172
  }
2173
+ if not _dsh_desktop_launcher_available(dsh):
2174
+ return {
2175
+ "root": str(plugin_root),
2176
+ "mcp_root": None, # 第三方 MCP bridge 已停用;通道由 profile patch 提供
2177
+ "profile": str(profile_root),
2178
+ "status": "staged",
2179
+ "detail": (
2180
+ "当前 dsh 是普通 CLI launcher;官方 CLI 不支持 plugin management,"
2181
+ "已保留 UI 包,等待 Desktop launcher 注册"
2182
+ ),
2183
+ }
1902
2184
  try:
1903
2185
  result = subprocess.run(
1904
2186
  [dsh, "plugin", "--profile", "web", "add", str(plugin_root)],
@@ -1966,46 +2248,49 @@ def _ensure_dsh_patch(root: Path) -> tuple[str, dict[str, object] | None]:
1966
2248
  The browser UI package is installed separately into the DSH web profile;
1967
2249
  agent presets do not load ``dsh.client`` modules.
1968
2250
  """
1969
- dsh_dir = root.resolve() / ".dsh"
1970
- dsh_dir.mkdir(parents=True, exist_ok=True)
1971
-
1972
- patch_path = dsh_dir / "patch.yml"
1973
- skill_path = dsh_dir / "skills" / "bugx" / "SKILL.md"
1974
- dsh_skill_path = dsh_dir / "skills" / "bugx-dsh" / "SKILL.md"
1975
- agent_path = dsh_dir / "agents" / "bugx.md"
2251
+ is_home_scope = _is_global_home_scope(root)
1976
2252
  patched = False
1977
- any_existing = any(path.exists() for path in (patch_path, skill_path, dsh_skill_path, agent_path))
1978
-
1979
- # Read bundled templates from integrations/dsh/
1980
- integration_dir = _integration_dir()
1981
- bundled_patch = integration_dir / "dsh" / "dsh-patch.yml"
1982
- bundled_skill = integration_dir / "dsh" / "skills" / "bugx" / "SKILL.md"
1983
- bundled_dsh_skill = integration_dir / "dsh" / "skills" / "bugx-dsh" / "SKILL.md"
1984
- bundled_agent = integration_dir / "dsh" / "agents" / "bugx.md"
1985
-
1986
- for bundled, target in (
1987
- (bundled_patch, patch_path),
1988
- (bundled_skill, skill_path),
1989
- (bundled_dsh_skill, dsh_skill_path),
1990
- (bundled_agent, agent_path),
1991
- ):
1992
- if not bundled.is_file():
1993
- raise CliError(_i18n_exc("agent.dsh_resource_missing", f"缺少 dsh 适配资源:{bundled}", bundled=bundled))
1994
- copied, _skipped, _backup = _write_host_resource(
1995
- root, target, bundled.read_bytes(), "dsh",
1996
- )
1997
- patched = patched or bool(copied)
1998
-
1999
- # 项目 patch 也要带官方 MCP overlay:`bugx doctor` 的「DeepSeek Harness
2000
- # MCP 配置」扫的是项目 `.dsh/patch.yml` 与全局预设,不是 profile patch。
2001
- # 只在 profile 层写入会让 install 之后 doctor 仍报「缺少 bugx-supervisor
2002
- # MCP」——修好调用却报告缺失,是更难排查的破窗。
2003
- if patch_path.is_file():
2004
- project_patch = patch_path.read_text(encoding="utf-8")
2005
- with_overlay = _ensure_official_mcp_overlay(project_patch, root)
2006
- if with_overlay != project_patch:
2007
- _atomic_write_global_file_tx(patch_path, with_overlay.encode("utf-8"))
2008
- patched = True
2253
+ any_existing = False
2254
+ if not is_home_scope:
2255
+ dsh_dir = root.resolve() / ".dsh"
2256
+ dsh_dir.mkdir(parents=True, exist_ok=True)
2257
+
2258
+ patch_path = dsh_dir / "patch.yml"
2259
+ skill_path = dsh_dir / "skills" / "bugx" / "SKILL.md"
2260
+ dsh_skill_path = dsh_dir / "skills" / "bugx-dsh" / "SKILL.md"
2261
+ agent_path = dsh_dir / "agents" / "bugx.md"
2262
+ any_existing = any(path.exists() for path in (patch_path, skill_path, dsh_skill_path, agent_path))
2263
+
2264
+ # Read bundled templates from integrations/dsh/
2265
+ integration_dir = _integration_dir()
2266
+ bundled_patch = integration_dir / "dsh" / "dsh-patch.yml"
2267
+ bundled_skill = integration_dir / "dsh" / "skills" / "bugx" / "SKILL.md"
2268
+ bundled_dsh_skill = integration_dir / "dsh" / "skills" / "bugx-dsh" / "SKILL.md"
2269
+ bundled_agent = integration_dir / "dsh" / "agents" / "bugx.md"
2270
+
2271
+ for bundled, target in (
2272
+ (bundled_patch, patch_path),
2273
+ (bundled_skill, skill_path),
2274
+ (bundled_dsh_skill, dsh_skill_path),
2275
+ (bundled_agent, agent_path),
2276
+ ):
2277
+ if not bundled.is_file():
2278
+ raise CliError(_i18n_exc("agent.dsh_resource_missing", f"缺少 dsh 适配资源:{bundled}", bundled=bundled))
2279
+ copied, _skipped, _backup = _write_host_resource(
2280
+ root, target, bundled.read_bytes(), "dsh",
2281
+ )
2282
+ patched = patched or bool(copied)
2283
+
2284
+ # 项目 patch 也要带官方 MCP overlay:`bugx doctor` 的「DeepSeek Harness
2285
+ # MCP 配置」扫的是项目 `.dsh/patch.yml` 与全局预设,不是 profile patch。
2286
+ # 只在 profile 层写入会让 install 之后 doctor 仍报「缺少 bugx-supervisor
2287
+ # MCP」——修好调用却报告缺失,是更难排查的破窗。
2288
+ if patch_path.is_file():
2289
+ project_patch = patch_path.read_text(encoding="utf-8")
2290
+ with_overlay = _ensure_official_mcp_overlay(project_patch, root)
2291
+ if with_overlay != project_patch:
2292
+ _atomic_write_global_file_tx(patch_path, with_overlay.encode("utf-8"))
2293
+ patched = True
2009
2294
 
2010
2295
  # Deploy BugX's agent preset and the browser UI bundle to their native
2011
2296
  # DSH user-level locations.
@@ -2015,6 +2300,8 @@ def _ensure_dsh_patch(root: Path) -> tuple[str, dict[str, object] | None]:
2015
2300
  except (CliError, OSError) as exc:
2016
2301
  raise CliError(_i18n_exc("agent.dsh_preset_write_failed", f"写入 dsh 全局预设失败:{exc}", exc=exc)) from exc
2017
2302
 
2303
+ if is_home_scope:
2304
+ return ("global_only", ui_plugin)
2018
2305
  if patched:
2019
2306
  return ("patched", ui_plugin) if any_existing else ("created", ui_plugin)
2020
2307
  return ("unchanged", ui_plugin)
@@ -2075,9 +2362,9 @@ def _deploy_dsh_preset(root: Path) -> None:
2075
2362
 
2076
2363
  preset_name = "BugX 深度审计"
2077
2364
  preset_desc = (
2078
- "你的自动化代码安全体检专家。深度排查项目中隐藏的逻辑漏洞、鉴权越界与并发隐患,"
2079
- "不仅找 Bug,更能自动生成复现验证与修复建议。"
2080
- "适合在项目提测发版前、安全合规体检或排查疑难缺陷时开启;日常开发与普通交流不打扰。"
2365
+ "BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,"
2366
+ "减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;"
2367
+ "确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。"
2081
2368
  )
2082
2369
  preset_order = 0
2083
2370
 
@@ -2139,10 +2426,69 @@ _DSH_PTC_WORKFLOW_PLUGIN = "@deepseek-ai/dsh-workflow-ptc"
2139
2426
  def _dsh_desktop_asar_candidates() -> list[Path]:
2140
2427
  """Return DSH Desktop ``app.asar`` paths that may carry the bundled runtime."""
2141
2428
  resources = Path("Contents", "Resources", "app.asar")
2142
- return [
2429
+ candidates = [
2143
2430
  Path.home().resolve() / "Applications" / "DSH Desktop.app" / resources,
2144
2431
  Path("/Applications") / "DSH Desktop.app" / resources,
2145
2432
  ]
2433
+ if os.name == "nt":
2434
+ # DSH Desktop is an Electron app on Windows. Keep this list bounded to
2435
+ # documented installation roots; never walk the drive looking for an
2436
+ # app.asar file.
2437
+ bases: list[Path] = []
2438
+ for variable in ("LOCALAPPDATA", "PROGRAMFILES", "PROGRAMFILES(X86)", "PROGRAMW6432"):
2439
+ value = os.environ.get(variable, "").strip()
2440
+ if value:
2441
+ bases.append(Path(value))
2442
+ local_app_data = os.environ.get("LOCALAPPDATA", "").strip()
2443
+ if not local_app_data:
2444
+ bases.append(Path.home() / "AppData" / "Local")
2445
+ for base in bases:
2446
+ candidates.extend((
2447
+ base / "Programs" / "DeepSeek Harness" / "resources" / "app.asar",
2448
+ base / "Programs" / "DeepSeekHarness" / "resources" / "app.asar",
2449
+ base / "DeepSeek Harness" / "resources" / "app.asar",
2450
+ base / "DeepSeekHarness" / "resources" / "app.asar",
2451
+ ))
2452
+
2453
+ unique: list[Path] = []
2454
+ seen: set[str] = set()
2455
+ for candidate in candidates:
2456
+ key = os.path.normcase(os.path.normpath(str(candidate)))
2457
+ if key not in seen:
2458
+ seen.add(key)
2459
+ unique.append(candidate)
2460
+ return unique
2461
+
2462
+
2463
+ def _dsh_directory_exists(path: Path) -> bool:
2464
+ """Check a DSH package directory, including a junction/symlink target."""
2465
+ try:
2466
+ return path.is_dir() or Path(os.path.realpath(path)).is_dir()
2467
+ except OSError:
2468
+ return False
2469
+
2470
+
2471
+ def _dsh_desktop_launcher_available(dsh: str) -> bool:
2472
+ """Return whether ``dsh`` is the Desktop launcher allowed to manage plugins.
2473
+
2474
+ The official CLI documentation states that npm/Python launchers reject
2475
+ plugin-management requests; only the Desktop-installed command may manage
2476
+ the initialized Desktop profile. Calling the former on Windows can crash
2477
+ the child process instead of returning a useful error, so path-gate the
2478
+ operation before spawning it.
2479
+ """
2480
+ try:
2481
+ launcher = Path(dsh).resolve()
2482
+ except OSError:
2483
+ launcher = Path(dsh)
2484
+ for asar in _dsh_desktop_asar_candidates():
2485
+ install_root = asar.parent.parent
2486
+ try:
2487
+ launcher.relative_to(install_root)
2488
+ except ValueError:
2489
+ continue
2490
+ return True
2491
+ return False
2146
2492
 
2147
2493
 
2148
2494
  def _asar_lists_bundled_package(asar: Path, package: str) -> bool:
@@ -2166,6 +2512,9 @@ def _asar_lists_bundled_package(asar: Path, package: str) -> bool:
2166
2512
  return False
2167
2513
  # The asar header is a nested file tree, so the package path never appears
2168
2514
  # as one contiguous byte string; parse the JSON and walk the "files" maps.
2515
+ # DSH Desktop currently nests the runtime below ``files/dsh`` rather than
2516
+ # putting ``node_modules`` at the archive root, so do not assume one fixed
2517
+ # number of parent directories.
2169
2518
  start = header.find(b'{"files":')
2170
2519
  if start < 0:
2171
2520
  return False
@@ -2175,12 +2524,22 @@ def _asar_lists_bundled_package(asar: Path, package: str) -> bool:
2175
2524
  )
2176
2525
  except (UnicodeDecodeError, json.JSONDecodeError):
2177
2526
  return False
2178
- node: Any = tree
2179
- for part in ("files", "node_modules", "files", "@deepseek-ai", "files", package):
2527
+ stack: list[tuple[Any, tuple[str, ...]]] = [(tree, ())]
2528
+ while stack:
2529
+ node, path = stack.pop()
2180
2530
  if not isinstance(node, dict):
2181
- return False
2182
- node = node.get(part)
2183
- return isinstance(node, dict)
2531
+ continue
2532
+ files = node.get("files")
2533
+ if not isinstance(files, dict):
2534
+ continue
2535
+ for name, child in files.items():
2536
+ if not isinstance(name, str):
2537
+ continue
2538
+ child_path = path + (name,)
2539
+ if child_path[-3:] == ("node_modules", "@deepseek-ai", package):
2540
+ return True
2541
+ stack.append((child, child_path))
2542
+ return False
2184
2543
 
2185
2544
 
2186
2545
  def _dsh_desktop_runtime_names() -> tuple[str, str] | None:
@@ -2210,16 +2569,20 @@ def _dsh_runtime_plugin_names(home: Path) -> tuple[str, str]:
2210
2569
  内置在 app.asar 中,必须先探测 asar;其余 home 以
2211
2570
  ``profiles/node_modules`` 为准(那是其插件解析根)。
2212
2571
  """
2213
- if "dsh-desktop" in home.parts:
2572
+ # On Windows Desktop and the regular CLI share ``%USERPROFILE%\.dsh``;
2573
+ # the home path therefore does not identify the Desktop runtime. If a
2574
+ # bundled Desktop app.asar is present, prefer its package names on every
2575
+ # Windows home. macOS keeps the historical dedicated desktop-home guard.
2576
+ if os.name == "nt" or "dsh-desktop" in home.parts:
2214
2577
  detected = _dsh_desktop_runtime_names()
2215
2578
  if detected is not None:
2216
2579
  return detected
2217
2580
  base = home / "profiles" / "node_modules" / "@deepseek-ai"
2218
- if (base / "dsh-agent-preset").is_dir():
2581
+ if _dsh_directory_exists(base / "dsh-agent-preset"):
2219
2582
  preset_plugin = "@deepseek-ai/dsh-agent-preset"
2220
2583
  else:
2221
2584
  preset_plugin = "@deepseek-ai/dsh-agent-presets"
2222
- if (base / "dsh-workflow-ptc").is_dir():
2585
+ if _dsh_directory_exists(base / "dsh-workflow-ptc"):
2223
2586
  workflow_plugin = _DSH_PTC_WORKFLOW_PLUGIN
2224
2587
  else:
2225
2588
  workflow_plugin = _DSH_LEGACY_WORKFLOW_PLUGIN
@@ -2461,9 +2824,10 @@ def _sync_one_profile_patch(
2461
2824
  else:
2462
2825
  updated = f"{content.rstrip()}\n\n{patch_block}\n"
2463
2826
 
2464
- if root is None:
2465
- raise CliError("_sync_one_profile_patch 需要 root 以绝对化 MCP --root/--db(F-RSI-20261119-015)")
2466
- updated = _ensure_official_mcp_overlay(updated, root)
2827
+ if root is None or _is_global_home_scope(root):
2828
+ updated = _ensure_official_mcp_overlay(updated, root or Path.home())
2829
+ else:
2830
+ updated = _ensure_official_mcp_overlay(updated, root)
2467
2831
 
2468
2832
  if updated != content:
2469
2833
  _atomic_write_global_file_tx(patch_path, updated.encode("utf-8"))
@@ -2504,9 +2868,43 @@ def _ensure_official_mcp_overlay(content: str, root: Path) -> str:
2504
2868
  不再承载 MCP,若 install 也不写,doctor 就会判定「缺少 bugx-supervisor
2505
2869
  MCP」,形成「修好调用却报告缺失」的新破窗。
2506
2870
  """
2507
- root_text = str(Path(root).resolve())
2871
+ global_scope = _is_global_home_scope(root)
2872
+ if global_scope:
2873
+ existing_match = re.search(
2874
+ r"^\s*-\s*['\"]?--root['\"]?\s*\n\s*-\s*['\"]?([^'\"\n]+)['\"]?",
2875
+ content,
2876
+ re.MULTILINE,
2877
+ )
2878
+ preserved_root: str | None = None
2879
+ if existing_match:
2880
+ candidate_text = existing_match.group(1).strip()
2881
+ if candidate_text and candidate_text not in {".", "{ROOT}"}:
2882
+ try:
2883
+ candidate_path = Path(candidate_text).expanduser().resolve()
2884
+ if candidate_path.is_dir() and not _is_global_home_scope(candidate_path):
2885
+ preserved_root = str(candidate_path)
2886
+ except OSError:
2887
+ preserved_root = None
2888
+ if preserved_root is not None:
2889
+ servers_to_write = tuple(
2890
+ (name, [arg.replace("{ROOT}", preserved_root) for arg in argv])
2891
+ for name, argv in _OFFICIAL_MCP_SERVERS
2892
+ )
2893
+ else:
2894
+ servers_to_write = (
2895
+ ("bugx-supervisor", ["mcp", "serve", "--role", "host"]),
2896
+ ("bugx-supervisor-worker", ["mcp", "serve", "--role", "worker"]),
2897
+ ("bugx-docs", ["mcp", "docs", "serve"]),
2898
+ )
2899
+ else:
2900
+ root_text = str(Path(root).resolve())
2901
+ servers_to_write = tuple(
2902
+ (name, [arg.replace("{ROOT}", root_text) for arg in argv])
2903
+ for name, argv in _OFFICIAL_MCP_SERVERS
2904
+ )
2905
+
2508
2906
  lines = [_OFFICIAL_MCP_MARKER, "- insert:"]
2509
- for server_name, argv in _OFFICIAL_MCP_SERVERS:
2907
+ for server_name, argv in servers_to_write:
2510
2908
  lines.extend([
2511
2909
  f" - id: {server_name}",
2512
2910
  f" name: '{_OFFICIAL_MCP_CLIENT}'",
@@ -2517,7 +2915,7 @@ def _ensure_official_mcp_overlay(content: str, root: Path) -> str:
2517
2915
  " args:",
2518
2916
  ])
2519
2917
  lines.extend(
2520
- f" - '{arg.replace('{ROOT}', root_text)}'" for arg in argv
2918
+ f" - '{arg}'" for arg in argv
2521
2919
  )
2522
2920
  block = "\n".join(lines) + "\n"
2523
2921
 
@@ -3174,22 +3572,22 @@ def _ensure_workbuddy_custom_expert(
3174
3572
  "---\n"
3175
3573
  "name: bugx\n"
3176
3574
  "description: >-\n"
3177
- " BugX 代码审计专家:专注于代码质量与安全的自主审查,深入分析代码逻辑、发现隐蔽缺陷并自动编写 PoC 验证,提供确凿的证据闭环与修复方案。\n"
3575
+ " BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。\n"
3178
3576
  "description_zh: >-\n"
3179
- " BugX 代码审计专家:专注于代码质量与安全的自主审查,深入分析代码逻辑、发现隐蔽缺陷并自动编写 PoC 验证,提供确凿的证据闭环与修复方案。\n"
3577
+ " BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。\n"
3180
3578
  "description_en: >-\n"
3181
- " BugX Code Auditor: Autonomous code quality and security auditing expert. Specializes in deep defect hunting, adversarial testing, PoC reproduction, and verified remediation.\n"
3579
+ " BugX is an autonomous code review and testing agent designed to safeguard software delivery: it surfaces hidden, deep bugs for developers right after writing code to eliminate painful debugging and rework; automates black-box, functional, and performance testing across complex edge cases for QA; and ensures software strictly meets functional requirements with rock-solid stability and resilience. By taking over tedious verification, BugX frees engineers from manual grunt work, boosts team velocity, elevates code quality, and significantly lowers long-term maintenance costs—putting technology to work for people.\n"
3182
3580
  "tools: Bash,Read,Edit\n"
3183
3581
  "color: \"#08B7D4\"\n"
3184
3582
  "---\n\n"
3185
- "你是一位专业的代码质量与漏洞挖掘专家(BugX 代码审计专家)。你的核心使命是帮助开发者在代码合入、发布前或疑难故障排查时,进行深层次的代码审计、对抗性缺陷排查与自动化验证。\n\n"
3583
+ "你是一个具备自主代码审查与测试能力的智能体。你的核心使命是严把代码交付关:帮助开发人员在写完代码后自动排查隐藏的深层 Bug,减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;确保代码功能完全符合要求、在各种复杂环境下都能稳定运行、不崩溃不卡死,上线放心不翻车。\n\n"
3186
3584
  "## 核心工作原则\n"
3187
- "1. **证据驱动(Evidence-Driven)**:不凭空猜测 Bug,必须通过静态逻辑推演或最小复现测试(PoC)验证缺陷存在。\n"
3585
+ "1. **证据驱动(Evidence-Driven)**:不凭空猜测 Bug,必须通过静态逻辑推演、黑盒测试或功能验证实测证据。\n"
3188
3586
  "2. **闭环验证(Verification Loop)**:缺陷发现后,优先编写自动化回归单测,验证失败;给出修复方案后重新运行测试验证通过。\n"
3189
- "3. **安全与质量并重**:涵盖业务逻辑越权、并发死锁/竞态条件、边界值溢出、资源泄漏、SQL注入、SSRF等安全与稳定性隐患。\n\n"
3587
+ "3. **健壮与稳定并重**:涵盖业务逻辑完备性、并发死锁/竞态条件、边界值溢出、资源泄漏、异常与极端场景等稳定性隐患。\n\n"
3190
3588
  "## 协作流程\n"
3191
- "1. **审计准备**:读取目标文件、架构设计与历史提交记录,理清数据流向与契约约束。\n"
3192
- "2. **深入排查**:对输入校验、状态转移、异常处理、外部调用等关键节点进行对抗式推演。\n"
3589
+ "1. **审查准备**:读取目标文件、架构设计与历史提交记录,理清数据流向与契约约束。\n"
3590
+ "2. **深入排查**:对输入校验、状态转移、异常处理、极端边界等关键节点进行对抗式推演与自动化测试。\n"
3193
3591
  "3. **产出报告**:输出清晰的问题说明、触发条件、风险等级与最小修复代码。\n"
3194
3592
  )
3195
3593
  backup = _backup_host_resource(root, wb_name, agent_dest) if agent_dest.exists() else None
@@ -3213,26 +3611,26 @@ def _ensure_workbuddy_custom_expert(
3213
3611
  "en": "BugX"
3214
3612
  },
3215
3613
  "profession": {
3216
- "zh": "代码审计专家",
3217
- "en": "Code Audit Expert"
3614
+ "zh": "自主代码审查与测试智能体",
3615
+ "en": "Autonomous Code Review & Testing Agent"
3218
3616
  },
3219
- "description": "专注于代码质量与安全的自主审查智能体。专为深层缺陷排查而生——在功能写完、提 PR 或排查疑难 Bug 时,它能深入分析代码逻辑、发现隐蔽缺陷并自动编写 PoC 验证,提供确凿的证据闭环与修复方案。",
3617
+ "description": "BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。",
3220
3618
  "displayDescription": {
3221
- "zh": "专注于代码质量与安全的自主审查智能体。专为深层缺陷排查而生——在功能写完、提 PR 或排查疑难 Bug 时,它能深入分析代码逻辑、发现隐蔽缺陷并自动编写 PoC 验证,提供确凿的证据闭环与修复方案。",
3222
- "en": "Autonomous code quality and security auditing expert. Specializes in deep defect hunting, adversarial testing, PoC reproduction, and verified remediation."
3619
+ "zh": "BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。",
3620
+ "en": "BugX is an autonomous code review and testing agent designed to safeguard software delivery: it surfaces hidden, deep bugs for developers right after writing code to eliminate painful debugging and rework; automates black-box, functional, and performance testing across complex edge cases for QA; and ensures software strictly meets functional requirements with rock-solid stability and resilience. By taking over tedious verification, BugX frees engineers from manual grunt work, boosts team velocity, elevates code quality, and significantly lowers long-term maintenance costs—putting technology to work for people."
3223
3621
  },
3224
3622
  "avatar": "avatars/expert.png",
3225
3623
  "category": "development",
3226
3624
  "categoryId": "01-Development",
3227
3625
  "tags": [
3228
- {"zh": "代码审计", "en": "Code Audit"},
3229
- {"zh": "漏洞挖掘", "en": "Vulnerability"},
3230
- {"zh": "自动化测试", "en": "Automated Testing"}
3626
+ {"zh": "代码审查", "en": "Code Review"},
3627
+ {"zh": "智能测试", "en": "Automated Testing"},
3628
+ {"zh": "质量保障", "en": "Quality Assurance"}
3231
3629
  ],
3232
3630
  "quickPrompts": [
3233
- {"zh": "对当前代码库进行一次全面的代码审计与漏洞排查", "en": "Perform a comprehensive code audit and vulnerability check on the current codebase"},
3234
- {"zh": "排查最近提交的代码中潜在的并发与边界缺陷", "en": "Investigate potential concurrency and boundary defects in recent commits"},
3235
- {"zh": "针对已知 Bug 编写最小复现 PoC 并验证修复方案", "en": "Write a minimal reproduction PoC for an issue and verify the fix"}
3631
+ {"zh": "对当前代码库进行全面的代码审查与深层 Bug 排查", "en": "Perform a comprehensive code review and deep bug inspection on the current codebase"},
3632
+ {"zh": "自动化运行黑盒测试与功能验证,排查潜在边界缺陷", "en": "Run automated black-box tests and functional verification to catch edge-case bugs"},
3633
+ {"zh": "对最近提交的代码进行性能测试与稳定性验证", "en": "Run performance and stability tests on recent commits to ensure rock-solid delivery"}
3236
3634
  ],
3237
3635
  "agents": ["./agents/bugx.md"],
3238
3636
  "skills": ["./skills/bugx"]
@@ -3458,7 +3856,11 @@ def _preflight_opencode_mcp_config(root: Path) -> None:
3458
3856
 
3459
3857
 
3460
3858
  def _ensure_opencode_config(
3461
- root: Path, *, selected: set[str] | None = None,
3859
+ root: Path,
3860
+ *,
3861
+ selected: set[str] | None = None,
3862
+ docs_transport: str | None = None,
3863
+ docs_remote_url: str | None = None,
3462
3864
  ) -> tuple[str, Path | None]:
3463
3865
  """Create or safely merge the bundled OpenCode MCP configuration.
3464
3866
 
@@ -3503,6 +3905,15 @@ def _ensure_opencode_config(
3503
3905
  for name in list(bundled_servers):
3504
3906
  if name not in keep:
3505
3907
  bundled_servers.pop(name, None)
3908
+ from .plugin import resolve_effective_docs_transport
3909
+ effective_docs_transport = resolve_effective_docs_transport(docs_transport, docs_remote_url)
3910
+ if effective_docs_transport == "remote" and "bugx-docs" in bundled_servers:
3911
+ from .plugin import _resolve_docs_remote_url
3912
+ bundled_servers["bugx-docs"] = {
3913
+ "type": "remote",
3914
+ "url": _resolve_docs_remote_url(docs_remote_url),
3915
+ "codemode": False,
3916
+ }
3506
3917
  if target.exists():
3507
3918
  if not target.is_file():
3508
3919
  raise CliError(_i18n_exc("agent.opencode_config_not_regular_file", f"OpenCode 配置不是普通文件: {target}", target=target))
@@ -3549,13 +3960,26 @@ def _ensure_opencode_config(
3549
3960
  name for name in managed_names
3550
3961
  if not isinstance(servers.get(name), dict)
3551
3962
  ]
3552
- if not missing and not remove_unavailable_optional and not configuration_changed:
3963
+ docs_entry = servers.get("bugx-docs")
3964
+ desired_docs = bundled_servers.get("bugx-docs")
3965
+ docs_transport_mismatch = (
3966
+ isinstance(docs_entry, dict)
3967
+ and isinstance(desired_docs, dict)
3968
+ and _mcp_entry_state("bugx-docs", docs_entry) == "configured"
3969
+ and (
3970
+ (effective_docs_transport == "remote" and docs_entry.get("url") != desired_docs.get("url"))
3971
+ or (effective_docs_transport == "stdio" and isinstance(docs_entry.get("url"), str))
3972
+ )
3973
+ )
3974
+ if not missing and not remove_unavailable_optional and not docs_transport_mismatch and not configuration_changed:
3553
3975
  return "unchanged", None
3554
3976
  backup = _backup_opencode_config(root, target)
3555
3977
  for name in remove_unavailable_optional:
3556
3978
  servers.pop(name, None)
3557
3979
  for name in missing:
3558
3980
  servers[name] = copy.deepcopy(bundled_servers[name])
3981
+ if docs_transport_mismatch and desired_docs is not None:
3982
+ servers["bugx-docs"] = copy.deepcopy(desired_docs)
3559
3983
  updated = json.dumps(payload, ensure_ascii=False, indent=2) + "\n"
3560
3984
  descriptor, temporary = tempfile.mkstemp(
3561
3985
  dir=str(target.parent), prefix=f".{target.name}.", suffix=".tmp",
@@ -3651,17 +4075,24 @@ def _check_host_mcp_config(root: Path, host_name: str, *, repair: bool = False)
3651
4075
  if not dsh_client or not isinstance(ui_name, str):
3652
4076
  ui_detail = ";DSH UI 包 manifest 缺少 dsh.client 或 ./client 导出"
3653
4077
  elif profile.is_file() and (ui_name not in bundles or ui_name not in dependencies):
3654
- ui_detail = ";DSH UI 包未注册到 web profile,请重新运行 bugx install --agent dsh"
4078
+ ui_detail = ";DSH UI 包已暂存就绪(CLI/Desktop 通道可用;可选 web profile 注册未激活)"
3655
4079
  elif not profile.is_file():
3656
4080
  ui_detail = ";已暂存 DSH UI 包(当前未发现 web profile)"
3657
4081
  else:
3658
4082
  ui_detail = ";DSH UI 图标包已注册到 web profile"
3659
- if patch_file.is_file() or user_preset.is_file():
4083
+ profile_patches = [
4084
+ _dsh_home() / "profiles" / profile_name / "cordis.patch.yml"
4085
+ for profile_name in ("web", "desktop")
4086
+ ]
4087
+ if patch_file.is_file() or user_preset.is_file() or any(p.is_file() for p in profile_patches):
3660
4088
  content = ""
3661
4089
  if patch_file.is_file():
3662
4090
  content += patch_file.read_text(encoding="utf-8", errors="ignore")
3663
4091
  if user_preset.is_file():
3664
4092
  content += user_preset.read_text(encoding="utf-8", errors="ignore")
4093
+ for p_patch in profile_patches:
4094
+ if p_patch.is_file():
4095
+ content += p_patch.read_text(encoding="utf-8", errors="ignore")
3665
4096
  has_supervisor = "bugx-supervisor" in content or "mcp-client" in content
3666
4097
  has_native_question = "@deepseek-ai/dsh-tool-ask-user" in content
3667
4098
  if has_supervisor and has_native_question:
@@ -3880,11 +4311,8 @@ def _check_host_mcp_config(root: Path, host_name: str, *, repair: bool = False)
3880
4311
  return True, "WorkBuddy `.workbuddy` 与 CodeBuddy 兼容 Skill 入口、Connector 图标包均已就绪;" + user_detail + venv_detail
3881
4312
 
3882
4313
  if host_name == HOST_NAME_QODER:
3883
- qoder_mcp = root / ".qoder" / "mcp.json"
3884
- project_mcp = root / ".mcp.json"
3885
- candidates = (
3886
- (qoder_mcp, "flat"),
3887
- (project_mcp, "flat"),
4314
+ candidates = tuple(
4315
+ (root / relative, "flat") for relative in reversed(QODER_PROJECT_MCP_PATHS)
3888
4316
  )
3889
4317
  from .plugin_qoder import _clean_legacy_qoder_plugin_and_skills, _qoder_user_agents_dir
3890
4318
 
@@ -3929,7 +4357,9 @@ def _check_host_mcp_config(root: Path, host_name: str, *, repair: bool = False)
3929
4357
  if has_legacy:
3930
4358
  legacy_warning = ";发现用户级 Qoder 遗留配置,可运行 `bugx doctor --repair` 清理"
3931
4359
 
3932
- ok, detail = _validate_host_supervisor_mcp(candidates, root)
4360
+ ok, detail = _validate_host_supervisor_mcp(
4361
+ candidates, root, merge_servers=True, entry_is_current=_qoder_mcp_entry_is_current,
4362
+ )
3933
4363
  user_agents_dir = _qoder_user_agents_dir()
3934
4364
  user_main = user_agents_dir / "bugx.md"
3935
4365
  user_worker = user_agents_dir / "bugx-worker.md"
@@ -3946,7 +4376,9 @@ def _check_host_mcp_config(root: Path, host_name: str, *, repair: bool = False)
3946
4376
  _ensure_qoder_user_agents(root, source=asset_root())
3947
4377
  if not ok:
3948
4378
  write_host_mcp_config(root, host_name)
3949
- ok, detail = _validate_host_supervisor_mcp(candidates, root)
4379
+ ok, detail = _validate_host_supervisor_mcp(
4380
+ candidates, root, merge_servers=True, entry_is_current=_qoder_mcp_entry_is_current,
4381
+ )
3950
4382
  missing_user = [
3951
4383
  name for name, path in (("bugx", user_main), ("bugx-worker", user_worker))
3952
4384
  if not path.is_file()