bugx-cli 0.1.1 → 0.1.3

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 (131) hide show
  1. package/README.md +36 -35
  2. package/core/README.md +1 -1
  3. package/core/agent/agent_orchestrator.py +3 -0
  4. package/core/agent/agent_workspace.py +14 -2
  5. package/core/assets/README.md +3 -2
  6. package/core/assets/bugx-social-preview.svg +71 -0
  7. package/core/assets/bugx-wechat-group.png +0 -0
  8. package/core/assets/twitter_promo_art.jpg +0 -0
  9. package/core/assets/twitter_promo_card.svg +166 -0
  10. package/core/assets/twitter_promo_clean.jpg +0 -0
  11. package/core/assets/twitter_terminal_real.png +0 -0
  12. package/core/audit_packs/README.md +2 -0
  13. package/core/audit_packs/pitfalls/auth_crypto.json +64 -0
  14. package/core/audit_packs/pitfalls/file_ssrf_cmd.json +64 -0
  15. package/core/audit_packs/pitfalls/go_backend.json +66 -0
  16. package/core/audit_packs/pitfalls/java_spring.json +64 -0
  17. package/core/audit_packs/pitfalls/js_ts_web.json +67 -0
  18. package/core/audit_packs/pitfalls/python_web.json +82 -0
  19. package/core/bugx.md +2 -2
  20. package/core/bugx_paths.py +2 -2
  21. package/core/cli-help.txt +1 -1
  22. package/core/cloud_sync/cloud_client.py +56 -5
  23. package/core/cloud_sync/consent.py +33 -3
  24. package/core/cloud_sync/flywheel_client.py +186 -24
  25. package/core/contracts/README.md +1 -1
  26. package/core/contracts/bugx-opencode.md +1 -1
  27. package/core/contracts/bugx-runtime-contract.md +1 -1
  28. package/core/contracts/bugx-worker.md +1 -1
  29. package/core/engine-integrity.json +191 -95
  30. package/core/host_acp/kimi.py +175 -0
  31. package/core/host_acp/minimax.py +28 -0
  32. package/core/host_runtime/host_registry.py +23 -3
  33. package/core/hosts/dsh.py +1 -1
  34. package/core/hosts/kimi.py +293 -0
  35. package/core/hosts/minimax.py +248 -0
  36. package/core/hosts/zcode.py +5 -0
  37. package/core/infra/README.md +1 -1
  38. package/core/infra/build_info.py +30 -5
  39. package/core/launch_phases/README.md +6 -3
  40. package/core/launch_phases/finding_confirm_phase.py +168 -7
  41. package/core/launch_phases/post_phase.py +5 -5
  42. package/core/launch_phases/pre_recon_scout.py +13 -0
  43. package/core/launch_phases/report_sharing.py +3 -7
  44. package/core/launch_phases/round_orchestrator.py +114 -26
  45. package/core/launch_phases/semantic_recon.py +545 -0
  46. package/core/launch_phases/startup_version_gate.py +6 -2
  47. package/core/launch_phases/supervisor_bridge.py +14 -23
  48. package/core/launch_phases/verify_loop.py +767 -0
  49. package/core/launch_phases/worker_prior.py +115 -0
  50. package/core/ledger/README.md +2 -1
  51. package/core/ledger/finding_verification.py +511 -2
  52. package/core/ledger/fp_ledger.py +255 -0
  53. package/core/metadata.txt +2 -2
  54. package/core/planning/README.md +2 -1
  55. package/core/planning/prompt_harness.py +50 -10
  56. package/core/planning/prompt_policy_engine.py +386 -0
  57. package/core/prompts/README.md +4 -2
  58. package/core/prompts/policies/prompt_policies.json +101 -0
  59. package/core/prompts/stages/stage_verify.defensive.md +42 -0
  60. package/core/prompts/stages/stage_verify.md +44 -0
  61. package/core/report_engine/report_share.py +0 -8
  62. package/core/retrieval/README.md +2 -1
  63. package/core/retrieval/pitfall_packs.py +277 -0
  64. package/core/runtime/README.md +1 -1
  65. package/core/runtime/global_telemetry.py +20 -0
  66. package/core/runtime/scenario_eval.py +1 -1
  67. package/core/runtime/setup_ui_env.py +4 -7
  68. package/core/supervisor/README.md +1 -1
  69. package/core/supervisor/cli.py +2 -2
  70. package/core/webui/mcp_inspector.py +6 -0
  71. package/core/webui/static/index.html +51 -3
  72. package/core/webui/static/manifest.webmanifest +1 -1
  73. package/core/webui/static/project-settings.js +18 -3
  74. package/core/webui/static/robots.txt +36 -0
  75. package/core/webui/static/sitemap.xml +15 -0
  76. package/docs/07_distribution/01_README_NPM.md +36 -35
  77. package/ecosystem/integrations/cline/skills/bugx/SKILL.md +1 -1
  78. package/ecosystem/integrations/dsh/agents/bugx.md +1 -1
  79. package/ecosystem/integrations/dsh/dsh-patch.yml +2 -2
  80. package/ecosystem/integrations/dsh/mcp/package.json +1 -1
  81. package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +1 -1
  82. package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +1 -1
  83. package/ecosystem/integrations/dsh/ui/package.json +1 -1
  84. package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +1 -1
  85. package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
  86. package/ecosystem/integrations/pi/skills/bugx/SKILL.md +1 -1
  87. package/ecosystem/integrations/qoder/connector-meta.json +9 -9
  88. package/ecosystem/integrations/workbuddy/connector-meta.json +9 -9
  89. package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +2 -2
  90. package/ecosystem/plugins/bugx/.claude-plugin/marketplace.json +2 -2
  91. package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +2 -2
  92. package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +4 -4
  93. package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +2 -2
  94. package/ecosystem/plugins/bugx/agents/bugx-worker.md +1 -1
  95. package/ecosystem/plugins/bugx/agents/bugx.md +1 -1
  96. package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +3 -3
  97. package/ecosystem/plugins/bugx/skills/bugx-claude/SKILL.md +1 -1
  98. package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +1 -1
  99. package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +1 -1
  100. package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +1 -1
  101. package/interfaces/bin/bugx.js +9 -7
  102. package/interfaces/cli/bugx_cli/__init__.py +2 -2
  103. package/interfaces/cli/bugx_cli/cli.py +178 -67
  104. package/interfaces/cli/bugx_cli/commands/agent.py +313 -127
  105. package/interfaces/cli/bugx_cli/commands/audit.py +8 -7
  106. package/interfaces/cli/bugx_cli/commands/cloud.py +27 -19
  107. package/interfaces/cli/bugx_cli/commands/doctor.py +18 -0
  108. package/interfaces/cli/bugx_cli/commands/knowledge.py +3 -4
  109. package/interfaces/cli/bugx_cli/commands/lifecycle.py +54 -47
  110. package/interfaces/cli/bugx_cli/commands/plugin.py +9 -9
  111. package/interfaces/cli/bugx_cli/commands/plugin_claude.py +27 -13
  112. package/interfaces/cli/bugx_cli/commands/plugin_kimi.py +348 -0
  113. package/interfaces/cli/bugx_cli/commands/plugin_minimax.py +322 -0
  114. package/interfaces/cli/bugx_cli/commands/plugin_qoder.py +3 -4
  115. package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +4 -5
  116. package/interfaces/cli/bugx_cli/commands/project.py +6 -13
  117. package/interfaces/cli/bugx_cli/commands/system.py +577 -162
  118. package/interfaces/cli/bugx_cli/common.py +102 -15
  119. package/interfaces/cli/bugx_cli/host_adapters.py +150 -4
  120. package/interfaces/cli/bugx_cli/hosts/registry.py +4 -2
  121. package/interfaces/cli/bugx_cli/hosts/template_engine.py +10 -9
  122. package/interfaces/cli/bugx_cli/infra/engine_installer.py +21 -10
  123. package/interfaces/cli/bugx_cli/infra/host_sync.py +1 -1
  124. package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +2 -2
  125. package/package.json +54 -16
  126. package/pyproject.toml +64 -1
  127. package/scripts/sync-version.mjs +1 -1
  128. package/skills/README.md +25 -0
  129. package/skills/platform/bugx-user/SKILL.md +92 -0
  130. package/core/assets/bugx-hero-cn.png +0 -0
  131. package/core/assets/bugx-hero-en.png +0 -0
@@ -50,8 +50,10 @@ from ..host_adapters import (
50
50
  ENTRY_SKILL_PAYLOAD,
51
51
  ENTRY_USER_REGISTRATION,
52
52
  HOST_ADAPTERS,
53
+ HostAdapter,
53
54
  HOST_NAME_CLAUDE,
54
55
  HOST_NAME_FUNIDE,
56
+ HOST_NAME_KIMI,
55
57
  HOST_NAME_QODER,
56
58
  HOST_NAME_ZCODE,
57
59
  )
@@ -124,32 +126,54 @@ class _CliProgress:
124
126
  # Backward-compatible test/import name; the renderer is shared by all long CLI commands.
125
127
  _InstallProgress = _CliProgress
126
128
 
127
- #: **未迁移**宿主的安装面基线(逐宿主切片时删除对应项)。已迁移宿主的目录由
128
- #: ``HOST_ADAPTERS.managed_surfaces()``(插件 marker 投影)自动追加。
129
- #: **未迁移**宿主的用户级可见位置提示;已迁移宿主用 ``全局 <label> 可见``。
129
+ #: 安装事务始终保护的共享运行面。宿主目录由本次选中的适配器按需追加,
130
+ #: 避免安装一个宿主时因为另一个宿主的用户自定义链接而提前失败。
131
+ #: 宿主用户级注册后的「在哪里可见」提示。
130
132
  _USER_AGENT_VISIBILITY_HINTS = {
131
133
  "funide": "FunIDE 设置 → 智能体可见",
132
134
  }
133
135
 
134
136
 
135
137
  def _user_agent_visibility(host_name: str) -> str:
136
- """用户级注册后的「在哪里可见」提示(未迁移宿主走基线表)。"""
138
+ """返回用户级注册后的「在哪里可见」提示。"""
137
139
 
138
140
  hint = _USER_AGENT_VISIBILITY_HINTS.get(host_name)
139
141
  return hint or f"全局 {engine_host_label(host_name)} 可见"
140
142
 
141
143
 
142
- _BASE_AGENT_INSTALL_SURFACES = (
143
- ".bugx", ".opencode", ".claude", ".zcode", ".pi", ".agents",
144
- ".workbuddy", ".codebuddy", ".qoder", ".github",
145
- ".dsh", "plugins", CONFIG_NAME,
146
- )
147
- _AGENT_INSTALL_SURFACES = tuple(
148
- dict.fromkeys(
149
- list(_BASE_AGENT_INSTALL_SURFACES)
150
- + [surface for adapter in HOST_ADAPTERS for surface in adapter.managed_surfaces()]
151
- )
152
- )
144
+ _BASE_AGENT_INSTALL_SURFACES = (".bugx",)
145
+
146
+
147
+ def _agent_install_surfaces(
148
+ selected_adapters: tuple[HostAdapter, ...] | None = None,
149
+ ) -> tuple[str, ...]:
150
+ """Return the project surfaces that this transaction may write.
151
+
152
+ ``None`` preserves the complete registry projection for direct in-process
153
+ callers. The CLI install path passes the selected adapters so an unrelated
154
+ host directory cannot veto the transaction.
155
+ """
156
+ adapters = HOST_ADAPTERS if selected_adapters is None else selected_adapters
157
+ surfaces = list(_BASE_AGENT_INSTALL_SURFACES)
158
+ plugins = {
159
+ str(plugin.identity.name): plugin
160
+ for plugin in engine_host_plugins()
161
+ if getattr(plugin, "identity", None) is not None
162
+ }
163
+ for adapter in adapters:
164
+ surfaces.extend(adapter.managed_surfaces())
165
+ if adapter.supports(CAP_PROJECT_MCP_CONFIG):
166
+ surfaces.append(CONFIG_NAME)
167
+ plugin = plugins.get(adapter.name)
168
+ if plugin is not None:
169
+ for relative in plugin.install.mcp_relpaths:
170
+ path = Path(relative)
171
+ if not path.is_absolute() and path.parts:
172
+ surfaces.append(path.parts[0])
173
+ return tuple(dict.fromkeys(surfaces))
174
+
175
+
176
+ _AGENT_INSTALL_SURFACES = _agent_install_surfaces()
153
177
 
154
178
  # The transaction protects only BugX-owned files that the install path can
155
179
  # write. It must never copy an entire host directory: user-level installs
@@ -328,8 +352,12 @@ def command_agent(args: argparse.Namespace) -> int:
328
352
  progress = _CliProgress(args)
329
353
  progress.update(0, "准备安装")
330
354
  root = args.root.resolve()
355
+ _ensure_core_importable()
356
+ selected_adapters = _select_install_adapters(
357
+ args, root, discover_hosts(root),
358
+ )
331
359
  try:
332
- staging, existed = _agent_install_snapshot(root)
360
+ staging, existed = _agent_install_snapshot(root, selected_adapters)
333
361
  except (OSError, shutil.Error) as exc:
334
362
  raise CliError(_i18n_exc(
335
363
  "agent.install_snapshot_failed",
@@ -339,7 +367,11 @@ def command_agent(args: argparse.Namespace) -> int:
339
367
  token = _GLOBAL_TX.set(staging)
340
368
  preserve_staging = False
341
369
  try:
342
- return _command_agent_impl(args, progress=progress)
370
+ return _command_agent_impl(
371
+ args,
372
+ progress=progress,
373
+ selected_adapters=selected_adapters,
374
+ )
343
375
  except BaseException as install_error:
344
376
  progress.fail()
345
377
  rollback_errors: list[str] = []
@@ -391,7 +423,10 @@ def _ignore_install_snapshot_entries(directory: str, names: list[str]) -> list[s
391
423
  return [name for name in names if _is_special_install_entry(Path(directory) / name)]
392
424
 
393
425
 
394
- def _agent_install_snapshot(root: Path) -> tuple[Path, dict[str, bool]]:
426
+ def _agent_install_snapshot(
427
+ root: Path,
428
+ selected_adapters: tuple[HostAdapter, ...] | None = None,
429
+ ) -> tuple[Path, dict[str, bool]]:
395
430
  """Stage only BugX-owned files before a host install.
396
431
 
397
432
  Installation touches shared runtime files as well as one or more host
@@ -403,7 +438,7 @@ def _agent_install_snapshot(root: Path) -> tuple[Path, dict[str, bool]]:
403
438
  staging = Path(tempfile.mkdtemp(prefix="bugx-install-transaction-")).resolve()
404
439
  existed: dict[str, bool] = {}
405
440
  try:
406
- for relative in _AGENT_INSTALL_SURFACES:
441
+ for relative in _agent_install_surfaces(selected_adapters):
407
442
  target = root / relative
408
443
  existed[relative] = target.exists() or _is_reparse_point(target)
409
444
  if not existed[relative]:
@@ -736,34 +771,14 @@ def _installed_engine_build_id() -> int:
736
771
  pass
737
772
  return get_build_id() or 1
738
773
 
739
- def _command_agent_impl(
740
- args: argparse.Namespace, *, progress: _CliProgress | None = None,
741
- ) -> int:
742
- """发现并安装到宿主 AI;不启动宿主,也不执行审计。"""
743
- root = args.root.resolve()
744
- command = getattr(args, "agent_command", "install")
745
- _ensure_core_importable()
746
- import core.i18n as i18n
747
- deployment_locale = i18n.resolve_locale().resolved_locale
748
- if getattr(args, "locale", None):
749
- norm = i18n.normalize_locale(args.locale)
750
- if not norm:
751
- raise CliError(_i18n_exc("common.invalid_locale", f"不支持的 locale: {args.locale};可选:zh-CN, en-US", locale=args.locale))
752
- deployment_locale = norm
753
- hosts = discover_hosts(root)
754
- if command == "discover":
755
- payload = {"root": str(root), "hosts": hosts, "execution": "none"}
756
- if args.json:
757
- print(json.dumps(payload, ensure_ascii=False, indent=2))
758
- else:
759
- for item in hosts:
760
- state = "FOUND" if item["installed"] else "NOT_FOUND"
761
- executable = item["executable"] or item.get("app_path") or "-"
762
- print(f"{item['name']}\t{state}\t{executable}\t{item['install_path']}")
763
- return 0
764
- if command != "install":
765
- raise CliError(_i18n_exc("agent.unknown_agent_command", f"未知 Agent 命令: {command}", command=command))
766
- raw_requested = []
774
+
775
+ def _select_install_adapters(
776
+ args: argparse.Namespace,
777
+ root: Path,
778
+ hosts: list[dict[str, object]],
779
+ ) -> tuple[HostAdapter, ...]:
780
+ """Resolve and validate the requested hosts before opening the transaction."""
781
+ raw_requested: list[str] = []
767
782
  for item in getattr(args, "agent", []):
768
783
  for sub in str(item).split(","):
769
784
  sub = sub.strip()
@@ -772,32 +787,38 @@ def _command_agent_impl(
772
787
  requested = list(dict.fromkeys(raw_requested))
773
788
  if not requested:
774
789
  if args.non_interactive:
775
- raise CliError(_i18n_exc("agent.non_interactive_agent_required", "非交互安装必须显式提供 --agent opencode/dsh/codex/cline/claude/zcode/workbuddy/pi/chatgpt/qoder/trea/funide"))
790
+ raise CliError(_i18n_exc(
791
+ "agent.non_interactive_agent_required",
792
+ "非交互安装必须显式提供 --agent "
793
+ + "/".join(adapter.name for adapter in HOST_ADAPTERS),
794
+ ))
776
795
  if not sys.stdin.isatty():
777
- raise CliError(_i18n_exc("agent.non_tty_agent_required", "当前不是交互终端;请显式提供 --agent"))
796
+ raise CliError(_i18n_exc(
797
+ "agent.non_tty_agent_required",
798
+ "当前不是交互终端;请显式提供 --agent",
799
+ ))
778
800
  requested = _prompt_for_hosts(hosts, root)
779
801
  if "all" in requested:
780
802
  available_names = [str(item["name"]) for item in hosts if item["installed"]]
781
803
  if not available_names and not args.allow_missing:
782
804
  raise CliError(_i18n_exc(
783
805
  "plugin.no_agent_detected",
784
- "没有检测到已安装的 AI Agent;请安装 OpenCode/Codex/Claude/ZCode/Pi/ChatGPT,"
785
- "或显式指定 --agent",
806
+ "没有检测到已安装的 AI Agent;请安装 OpenCode/Codex/Claude/ZCode/Pi/ChatGPT,或显式指定 --agent",
786
807
  ))
787
808
  if not available_names and args.allow_missing:
788
809
  available_names = [str(item["name"]) for item in hosts]
789
- expanded = []
810
+ expanded: list[str] = []
790
811
  for name in requested:
791
812
  if name == "all":
792
- for av in available_names:
793
- if av not in expanded:
794
- expanded.append(av)
795
- else:
796
- if name not in expanded:
797
- expanded.append(name)
813
+ for available in available_names:
814
+ if available not in expanded:
815
+ expanded.append(available)
816
+ elif name not in expanded:
817
+ expanded.append(name)
798
818
  requested = expanded
799
- selected = []
800
- seen_adapters = set()
819
+
820
+ selected: list[HostAdapter] = []
821
+ seen_adapters: set[str] = set()
801
822
  for name in requested:
802
823
  try:
803
824
  adapter = get_adapter(name)
@@ -808,8 +829,50 @@ def _command_agent_impl(
808
829
  seen_adapters.add(adapter.name)
809
830
  detected = next(item for item in hosts if item["name"] == adapter.name)
810
831
  if not detected["installed"] and not args.allow_missing:
811
- raise CliError(_i18n_exc("agent.adapter_missing_allow_missing", f"未检测到 {adapter.label};如仍要写入项目入口,请加 --allow-missing", label=adapter.label))
832
+ raise CliError(_i18n_exc(
833
+ "agent.adapter_missing_allow_missing",
834
+ f"未检测到 {adapter.label};如仍要写入项目入口,请加 --allow-missing",
835
+ label=adapter.label,
836
+ ))
812
837
  selected.append(adapter)
838
+ return tuple(selected)
839
+
840
+
841
+ def _command_agent_impl(
842
+ args: argparse.Namespace,
843
+ *,
844
+ progress: _CliProgress | None = None,
845
+ selected_adapters: tuple[HostAdapter, ...] | None = None,
846
+ ) -> int:
847
+ """发现并安装到宿主 AI;不启动宿主,也不执行审计。"""
848
+ root = args.root.resolve()
849
+ command = getattr(args, "agent_command", "install")
850
+ _ensure_core_importable()
851
+ import core.i18n as i18n
852
+ deployment_locale = i18n.resolve_locale().resolved_locale
853
+ if getattr(args, "locale", None):
854
+ norm = i18n.normalize_locale(args.locale)
855
+ if not norm:
856
+ raise CliError(_i18n_exc("common.invalid_locale", f"不支持的 locale: {args.locale};可选:zh-CN, en-US", locale=args.locale))
857
+ deployment_locale = norm
858
+ hosts = discover_hosts(root)
859
+ if command == "discover":
860
+ payload = {"root": str(root), "hosts": hosts, "execution": "none"}
861
+ if args.json:
862
+ print(json.dumps(payload, ensure_ascii=False, indent=2))
863
+ else:
864
+ for item in hosts:
865
+ state = "FOUND" if item["installed"] else "NOT_FOUND"
866
+ executable = item["executable"] or item.get("app_path") or "-"
867
+ print(f"{item['name']}\t{state}\t{executable}\t{item['install_path']}")
868
+ return 0
869
+ if command != "install":
870
+ raise CliError(_i18n_exc("agent.unknown_agent_command", f"未知 Agent 命令: {command}", command=command))
871
+ selected = list(
872
+ _select_install_adapters(args, root, hosts)
873
+ if selected_adapters is None
874
+ else selected_adapters
875
+ )
813
876
  if progress is not None:
814
877
  progress.update(10, "已确认安装目标")
815
878
 
@@ -1162,40 +1225,44 @@ def _command_agent_impl(
1162
1225
  "to": str(root),
1163
1226
  }
1164
1227
  host_mcp_configs[adapter.name] = host_info
1165
- if adapter.supports(CAP_USER_AGENT_REGISTRATION):
1166
- # User-level agent registrations share the install transaction;
1167
- # MCP files remain scoped to this project.
1168
- registered_user_agents = adapter.ensure_user_agents(
1169
- root, source, locale=deployment_locale,
1228
+ # User-level registrations are independent of project MCP writing.
1229
+ # MiniMax Plugin V1 has no project MCP container: its package owns both
1230
+ # the Agent manifests and servers.mcp.json under the user data root.
1231
+ for adapter in selected:
1232
+ if not adapter.supports(CAP_USER_AGENT_REGISTRATION):
1233
+ continue
1234
+ registered_user_agents = adapter.ensure_user_agents(
1235
+ root, source, locale=deployment_locale,
1236
+ )
1237
+ if registered_user_agents is None:
1238
+ raise CliError(
1239
+ f"{adapter.label} 声明支持用户级注册,但注册器没有返回结果;"
1240
+ "已阻断安装,避免报告成功但插件未生效。"
1170
1241
  )
1171
- if registered_user_agents is not None:
1172
- user_agents_by_host[adapter.name] = registered_user_agents
1173
- if adapter.name == HOST_NAME_ZCODE:
1174
- # ZCode 专属:用户级使用手册 Skill 与 agents 同事务部署
1175
- # (全局层,跨项目可见;内容随 wheel 版本演进)。
1176
- zcode_user_skill = _ensure_zcode_user_skill(root, source)
1177
- user_agents_by_host[adapter.name]["user_skill"] = (
1178
- zcode_user_skill
1179
- )
1180
- for item in zcode_user_skill["written"]:
1181
- if item["status"] == "unchanged":
1182
- continue
1183
- host_mcp_changes.append((
1184
- Path(str(item["path"])),
1185
- Path(str(item["backup"])) if item["backup"] else None,
1186
- bool(item["created"]),
1187
- ))
1188
- host_backups.extend(zcode_user_skill["backups"])
1189
- for item in registered_user_agents["written"]:
1190
-
1191
- if item["status"] == "unchanged":
1192
- continue
1193
- host_mcp_changes.append((
1194
- Path(str(item["path"])),
1195
- Path(str(item["backup"])) if item["backup"] else None,
1196
- bool(item["created"]),
1197
- ))
1198
- host_backups.extend(registered_user_agents["backups"])
1242
+ user_agents_by_host[adapter.name] = registered_user_agents
1243
+ if adapter.name == HOST_NAME_ZCODE:
1244
+ # ZCode 专属:用户级使用手册 Skill 与 agents 同事务部署
1245
+ # (全局层,跨项目可见;内容随 wheel 版本演进)。
1246
+ zcode_user_skill = _ensure_zcode_user_skill(root, source)
1247
+ user_agents_by_host[adapter.name]["user_skill"] = zcode_user_skill
1248
+ for item in zcode_user_skill["written"]:
1249
+ if item["status"] == "unchanged":
1250
+ continue
1251
+ host_mcp_changes.append((
1252
+ Path(str(item["path"])),
1253
+ Path(str(item["backup"])) if item["backup"] else None,
1254
+ bool(item["created"]),
1255
+ ))
1256
+ host_backups.extend(zcode_user_skill["backups"])
1257
+ for item in registered_user_agents["written"]:
1258
+ if item["status"] == "unchanged":
1259
+ continue
1260
+ host_mcp_changes.append((
1261
+ Path(str(item["path"])),
1262
+ Path(str(item["backup"])) if item["backup"] else None,
1263
+ bool(item["created"]),
1264
+ ))
1265
+ host_backups.extend(registered_user_agents["backups"])
1199
1266
  for adapter in selected:
1200
1267
  if adapter.supports(CAP_GLOBAL_AGENT_LINK):
1201
1268
  # global-agent-link 宿主(现仅 opencode):用户级使用手册 Skill
@@ -1414,11 +1481,11 @@ def _command_agent_impl(
1414
1481
  status = str(info["status"])
1415
1482
  path = str(info["path"])
1416
1483
  if status == "created":
1417
- print(f" {host_name} MCP 配置:已创建 {path}(host/worker 双通道)")
1484
+ print(f" {host_name} MCP 配置:已创建 {path}(host/worker 双通道,需重启宿主会话生效)")
1418
1485
  elif status == "unchanged":
1419
1486
  print(f" {host_name} MCP 配置:已是最新双通道配置,保持不变({path})")
1420
1487
  else:
1421
- print(f" {host_name} MCP 配置:已备份并{status}双通道({path})")
1488
+ print(f" {host_name} MCP 配置:已备份并{status}双通道({path},需重启宿主会话生效)")
1422
1489
  switched = info.get("root_switch")
1423
1490
  if isinstance(switched, dict):
1424
1491
  print(
@@ -1524,6 +1591,23 @@ def _command_agent_impl(
1524
1591
  f" Qoder 用户级资产:已是最新,保持不变"
1525
1592
  f"({qoder_user_agents['dir']})"
1526
1593
  )
1594
+ if (kimi_user_agents := user_agents_by_host.get(HOST_NAME_KIMI)) is not None:
1595
+ reported_user_agents.add(HOST_NAME_KIMI)
1596
+ changed = [
1597
+ item for item in kimi_user_agents["written"]
1598
+ if item["status"] != "unchanged"
1599
+ ]
1600
+ if changed:
1601
+ names = "、".join(Path(str(item["path"])).name for item in changed)
1602
+ print(
1603
+ f" Kimi 桌面端插件与徽标:已配置 {names}"
1604
+ f"({kimi_user_agents['dir']},免点击直接启用)"
1605
+ )
1606
+ else:
1607
+ print(
1608
+ f" Kimi 桌面端插件:已是最新并处于启用状态"
1609
+ f"({kimi_user_agents['dir']})"
1610
+ )
1527
1611
  # 其余宿主的用户级注册结果统一汇报(标签来自插件/组件表,不写宿主名)。
1528
1612
  for host_name, payload in user_agents_by_host.items():
1529
1613
  if host_name in reported_user_agents:
@@ -1589,7 +1673,22 @@ def _command_agent_impl(
1589
1673
  f" DSH UI 插件:已暂存 {dsh_ui_plugin['root']}({dsh_ui_plugin['detail']})"
1590
1674
  )
1591
1675
  print(" DSH Web 启动:dsh web(按当前 Session 工作区自动绑定;未选目录会明确提示)")
1676
+ mcp_restart_targets: list[str] = []
1677
+ for host_name, info in host_mcp_configs.items():
1678
+ if info.get("session_restart_required"):
1679
+ mcp_restart_targets.append(f"{host_name}: {info.get('path')}")
1592
1680
  if opencode_config_status in {"created", "merged"}:
1681
+ mcp_restart_targets.append(f"OpenCode: {CONFIG_NAME}")
1682
+
1683
+ if mcp_restart_targets:
1684
+ print("\n ========================================================")
1685
+ print(" ⚠【必须强制重启宿主会话】")
1686
+ print(" 项目 MCP 配置已新建/更新,宿主进程不支持动态热加载:")
1687
+ for target_desc in mcp_restart_targets:
1688
+ print(f" - {target_desc}")
1689
+ print(" 请务必执行:【重载窗口 / 重启宿主会话】后再启动 BugX!")
1690
+ print(" ========================================================\n")
1691
+ elif opencode_config_status in {"created", "merged"}:
1593
1692
  print(" ⚠ OpenCode MCP 配置已变化;现有会话通常不会热加载。启动 BugX 时会先主动探活,"
1594
1693
  "探活未命中时再提示重启 OpenCode 会话")
1595
1694
  _print_mcp_recommendations(mcp_recommendations)
@@ -1838,6 +1937,17 @@ def _deploy_dsh_ui_plugin() -> dict[str, object]:
1838
1937
  "status": "staged",
1839
1938
  "detail": "未发现可管理的 DSH web profile,保留包供 dsh plugin add 使用",
1840
1939
  }
1940
+ if not _dsh_desktop_launcher_available(dsh):
1941
+ return {
1942
+ "root": str(plugin_root),
1943
+ "mcp_root": None, # 第三方 MCP bridge 已停用;通道由 profile patch 提供
1944
+ "profile": str(profile_root),
1945
+ "status": "staged",
1946
+ "detail": (
1947
+ "当前 dsh 是普通 CLI launcher;官方 CLI 不支持 plugin management,"
1948
+ "已保留 UI 包,等待 Desktop launcher 注册"
1949
+ ),
1950
+ }
1841
1951
  try:
1842
1952
  result = subprocess.run(
1843
1953
  [dsh, "plugin", "--profile", "web", "add", str(plugin_root)],
@@ -2014,9 +2124,9 @@ def _deploy_dsh_preset(root: Path) -> None:
2014
2124
 
2015
2125
  preset_name = "BugX 深度审计"
2016
2126
  preset_desc = (
2017
- "你的自动化代码安全体检专家。深度排查项目中隐藏的逻辑漏洞、鉴权越界与并发隐患,"
2018
- "不仅找 Bug,更能自动生成复现验证与修复建议。"
2019
- "适合在项目提测发版前、安全合规体检或排查疑难缺陷时开启;日常开发与普通交流不打扰。"
2127
+ "BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,"
2128
+ "减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;"
2129
+ "确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。"
2020
2130
  )
2021
2131
  preset_order = 0
2022
2132
 
@@ -2078,10 +2188,69 @@ _DSH_PTC_WORKFLOW_PLUGIN = "@deepseek-ai/dsh-workflow-ptc"
2078
2188
  def _dsh_desktop_asar_candidates() -> list[Path]:
2079
2189
  """Return DSH Desktop ``app.asar`` paths that may carry the bundled runtime."""
2080
2190
  resources = Path("Contents", "Resources", "app.asar")
2081
- return [
2191
+ candidates = [
2082
2192
  Path.home().resolve() / "Applications" / "DSH Desktop.app" / resources,
2083
2193
  Path("/Applications") / "DSH Desktop.app" / resources,
2084
2194
  ]
2195
+ if os.name == "nt":
2196
+ # DSH Desktop is an Electron app on Windows. Keep this list bounded to
2197
+ # documented installation roots; never walk the drive looking for an
2198
+ # app.asar file.
2199
+ bases: list[Path] = []
2200
+ for variable in ("LOCALAPPDATA", "PROGRAMFILES", "PROGRAMFILES(X86)", "PROGRAMW6432"):
2201
+ value = os.environ.get(variable, "").strip()
2202
+ if value:
2203
+ bases.append(Path(value))
2204
+ local_app_data = os.environ.get("LOCALAPPDATA", "").strip()
2205
+ if not local_app_data:
2206
+ bases.append(Path.home() / "AppData" / "Local")
2207
+ for base in bases:
2208
+ candidates.extend((
2209
+ base / "Programs" / "DeepSeek Harness" / "resources" / "app.asar",
2210
+ base / "Programs" / "DeepSeekHarness" / "resources" / "app.asar",
2211
+ base / "DeepSeek Harness" / "resources" / "app.asar",
2212
+ base / "DeepSeekHarness" / "resources" / "app.asar",
2213
+ ))
2214
+
2215
+ unique: list[Path] = []
2216
+ seen: set[str] = set()
2217
+ for candidate in candidates:
2218
+ key = os.path.normcase(os.path.normpath(str(candidate)))
2219
+ if key not in seen:
2220
+ seen.add(key)
2221
+ unique.append(candidate)
2222
+ return unique
2223
+
2224
+
2225
+ def _dsh_directory_exists(path: Path) -> bool:
2226
+ """Check a DSH package directory, including a junction/symlink target."""
2227
+ try:
2228
+ return path.is_dir() or Path(os.path.realpath(path)).is_dir()
2229
+ except OSError:
2230
+ return False
2231
+
2232
+
2233
+ def _dsh_desktop_launcher_available(dsh: str) -> bool:
2234
+ """Return whether ``dsh`` is the Desktop launcher allowed to manage plugins.
2235
+
2236
+ The official CLI documentation states that npm/Python launchers reject
2237
+ plugin-management requests; only the Desktop-installed command may manage
2238
+ the initialized Desktop profile. Calling the former on Windows can crash
2239
+ the child process instead of returning a useful error, so path-gate the
2240
+ operation before spawning it.
2241
+ """
2242
+ try:
2243
+ launcher = Path(dsh).resolve()
2244
+ except OSError:
2245
+ launcher = Path(dsh)
2246
+ for asar in _dsh_desktop_asar_candidates():
2247
+ install_root = asar.parent.parent
2248
+ try:
2249
+ launcher.relative_to(install_root)
2250
+ except ValueError:
2251
+ continue
2252
+ return True
2253
+ return False
2085
2254
 
2086
2255
 
2087
2256
  def _asar_lists_bundled_package(asar: Path, package: str) -> bool:
@@ -2105,6 +2274,9 @@ def _asar_lists_bundled_package(asar: Path, package: str) -> bool:
2105
2274
  return False
2106
2275
  # The asar header is a nested file tree, so the package path never appears
2107
2276
  # as one contiguous byte string; parse the JSON and walk the "files" maps.
2277
+ # DSH Desktop currently nests the runtime below ``files/dsh`` rather than
2278
+ # putting ``node_modules`` at the archive root, so do not assume one fixed
2279
+ # number of parent directories.
2108
2280
  start = header.find(b'{"files":')
2109
2281
  if start < 0:
2110
2282
  return False
@@ -2114,12 +2286,22 @@ def _asar_lists_bundled_package(asar: Path, package: str) -> bool:
2114
2286
  )
2115
2287
  except (UnicodeDecodeError, json.JSONDecodeError):
2116
2288
  return False
2117
- node: Any = tree
2118
- for part in ("files", "node_modules", "files", "@deepseek-ai", "files", package):
2289
+ stack: list[tuple[Any, tuple[str, ...]]] = [(tree, ())]
2290
+ while stack:
2291
+ node, path = stack.pop()
2119
2292
  if not isinstance(node, dict):
2120
- return False
2121
- node = node.get(part)
2122
- return isinstance(node, dict)
2293
+ continue
2294
+ files = node.get("files")
2295
+ if not isinstance(files, dict):
2296
+ continue
2297
+ for name, child in files.items():
2298
+ if not isinstance(name, str):
2299
+ continue
2300
+ child_path = path + (name,)
2301
+ if child_path[-3:] == ("node_modules", "@deepseek-ai", package):
2302
+ return True
2303
+ stack.append((child, child_path))
2304
+ return False
2123
2305
 
2124
2306
 
2125
2307
  def _dsh_desktop_runtime_names() -> tuple[str, str] | None:
@@ -2149,16 +2331,20 @@ def _dsh_runtime_plugin_names(home: Path) -> tuple[str, str]:
2149
2331
  内置在 app.asar 中,必须先探测 asar;其余 home 以
2150
2332
  ``profiles/node_modules`` 为准(那是其插件解析根)。
2151
2333
  """
2152
- if "dsh-desktop" in home.parts:
2334
+ # On Windows Desktop and the regular CLI share ``%USERPROFILE%\.dsh``;
2335
+ # the home path therefore does not identify the Desktop runtime. If a
2336
+ # bundled Desktop app.asar is present, prefer its package names on every
2337
+ # Windows home. macOS keeps the historical dedicated desktop-home guard.
2338
+ if os.name == "nt" or "dsh-desktop" in home.parts:
2153
2339
  detected = _dsh_desktop_runtime_names()
2154
2340
  if detected is not None:
2155
2341
  return detected
2156
2342
  base = home / "profiles" / "node_modules" / "@deepseek-ai"
2157
- if (base / "dsh-agent-preset").is_dir():
2343
+ if _dsh_directory_exists(base / "dsh-agent-preset"):
2158
2344
  preset_plugin = "@deepseek-ai/dsh-agent-preset"
2159
2345
  else:
2160
2346
  preset_plugin = "@deepseek-ai/dsh-agent-presets"
2161
- if (base / "dsh-workflow-ptc").is_dir():
2347
+ if _dsh_directory_exists(base / "dsh-workflow-ptc"):
2162
2348
  workflow_plugin = _DSH_PTC_WORKFLOW_PLUGIN
2163
2349
  else:
2164
2350
  workflow_plugin = _DSH_LEGACY_WORKFLOW_PLUGIN
@@ -3113,22 +3299,22 @@ def _ensure_workbuddy_custom_expert(
3113
3299
  "---\n"
3114
3300
  "name: bugx\n"
3115
3301
  "description: >-\n"
3116
- " BugX 代码审计专家:专注于代码质量与安全的自主审查,深入分析代码逻辑、发现隐蔽缺陷并自动编写 PoC 验证,提供确凿的证据闭环与修复方案。\n"
3302
+ " BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。\n"
3117
3303
  "description_zh: >-\n"
3118
- " BugX 代码审计专家:专注于代码质量与安全的自主审查,深入分析代码逻辑、发现隐蔽缺陷并自动编写 PoC 验证,提供确凿的证据闭环与修复方案。\n"
3304
+ " BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。\n"
3119
3305
  "description_en: >-\n"
3120
- " BugX Code Auditor: Autonomous code quality and security auditing expert. Specializes in deep defect hunting, adversarial testing, PoC reproduction, and verified remediation.\n"
3306
+ " 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"
3121
3307
  "tools: Bash,Read,Edit\n"
3122
3308
  "color: \"#08B7D4\"\n"
3123
3309
  "---\n\n"
3124
- "你是一位专业的代码质量与漏洞挖掘专家(BugX 代码审计专家)。你的核心使命是帮助开发者在代码合入、发布前或疑难故障排查时,进行深层次的代码审计、对抗性缺陷排查与自动化验证。\n\n"
3310
+ "你是一个具备自主代码审查与测试能力的智能体。你的核心使命是严把代码交付关:帮助开发人员在写完代码后自动排查隐藏的深层 Bug,减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;确保代码功能完全符合要求、在各种复杂环境下都能稳定运行、不崩溃不卡死,上线放心不翻车。\n\n"
3125
3311
  "## 核心工作原则\n"
3126
- "1. **证据驱动(Evidence-Driven)**:不凭空猜测 Bug,必须通过静态逻辑推演或最小复现测试(PoC)验证缺陷存在。\n"
3312
+ "1. **证据驱动(Evidence-Driven)**:不凭空猜测 Bug,必须通过静态逻辑推演、黑盒测试或功能验证实测证据。\n"
3127
3313
  "2. **闭环验证(Verification Loop)**:缺陷发现后,优先编写自动化回归单测,验证失败;给出修复方案后重新运行测试验证通过。\n"
3128
- "3. **安全与质量并重**:涵盖业务逻辑越权、并发死锁/竞态条件、边界值溢出、资源泄漏、SQL注入、SSRF等安全与稳定性隐患。\n\n"
3314
+ "3. **健壮与稳定并重**:涵盖业务逻辑完备性、并发死锁/竞态条件、边界值溢出、资源泄漏、异常与极端场景等稳定性隐患。\n\n"
3129
3315
  "## 协作流程\n"
3130
- "1. **审计准备**:读取目标文件、架构设计与历史提交记录,理清数据流向与契约约束。\n"
3131
- "2. **深入排查**:对输入校验、状态转移、异常处理、外部调用等关键节点进行对抗式推演。\n"
3316
+ "1. **审查准备**:读取目标文件、架构设计与历史提交记录,理清数据流向与契约约束。\n"
3317
+ "2. **深入排查**:对输入校验、状态转移、异常处理、极端边界等关键节点进行对抗式推演与自动化测试。\n"
3132
3318
  "3. **产出报告**:输出清晰的问题说明、触发条件、风险等级与最小修复代码。\n"
3133
3319
  )
3134
3320
  backup = _backup_host_resource(root, wb_name, agent_dest) if agent_dest.exists() else None
@@ -3152,26 +3338,26 @@ def _ensure_workbuddy_custom_expert(
3152
3338
  "en": "BugX"
3153
3339
  },
3154
3340
  "profession": {
3155
- "zh": "代码审计专家",
3156
- "en": "Code Audit Expert"
3341
+ "zh": "自主代码审查与测试智能体",
3342
+ "en": "Autonomous Code Review & Testing Agent"
3157
3343
  },
3158
- "description": "专注于代码质量与安全的自主审查智能体。专为深层缺陷排查而生——在功能写完、提 PR 或排查疑难 Bug 时,它能深入分析代码逻辑、发现隐蔽缺陷并自动编写 PoC 验证,提供确凿的证据闭环与修复方案。",
3344
+ "description": "BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。",
3159
3345
  "displayDescription": {
3160
- "zh": "专注于代码质量与安全的自主审查智能体。专为深层缺陷排查而生——在功能写完、提 PR 或排查疑难 Bug 时,它能深入分析代码逻辑、发现隐蔽缺陷并自动编写 PoC 验证,提供确凿的证据闭环与修复方案。",
3161
- "en": "Autonomous code quality and security auditing expert. Specializes in deep defect hunting, adversarial testing, PoC reproduction, and verified remediation."
3346
+ "zh": "BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。",
3347
+ "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."
3162
3348
  },
3163
3349
  "avatar": "avatars/expert.png",
3164
3350
  "category": "development",
3165
3351
  "categoryId": "01-Development",
3166
3352
  "tags": [
3167
- {"zh": "代码审计", "en": "Code Audit"},
3168
- {"zh": "漏洞挖掘", "en": "Vulnerability"},
3169
- {"zh": "自动化测试", "en": "Automated Testing"}
3353
+ {"zh": "代码审查", "en": "Code Review"},
3354
+ {"zh": "智能测试", "en": "Automated Testing"},
3355
+ {"zh": "质量保障", "en": "Quality Assurance"}
3170
3356
  ],
3171
3357
  "quickPrompts": [
3172
- {"zh": "对当前代码库进行一次全面的代码审计与漏洞排查", "en": "Perform a comprehensive code audit and vulnerability check on the current codebase"},
3173
- {"zh": "排查最近提交的代码中潜在的并发与边界缺陷", "en": "Investigate potential concurrency and boundary defects in recent commits"},
3174
- {"zh": "针对已知 Bug 编写最小复现 PoC 并验证修复方案", "en": "Write a minimal reproduction PoC for an issue and verify the fix"}
3358
+ {"zh": "对当前代码库进行全面的代码审查与深层 Bug 排查", "en": "Perform a comprehensive code review and deep bug inspection on the current codebase"},
3359
+ {"zh": "自动化运行黑盒测试与功能验证,排查潜在边界缺陷", "en": "Run automated black-box tests and functional verification to catch edge-case bugs"},
3360
+ {"zh": "对最近提交的代码进行性能测试与稳定性验证", "en": "Run performance and stability tests on recent commits to ensure rock-solid delivery"}
3175
3361
  ],
3176
3362
  "agents": ["./agents/bugx.md"],
3177
3363
  "skills": ["./skills/bugx"]