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
@@ -14,6 +14,7 @@ import json
14
14
  import os
15
15
  import re
16
16
  import shutil
17
+ import stat
17
18
  import subprocess
18
19
  import sys
19
20
  import sysconfig
@@ -569,6 +570,10 @@ def _defer_command_logging_until_authorized(args: argparse.Namespace) -> bool:
569
570
  not create/open the project log until authorization has succeeded.
570
571
  """
571
572
  command = getattr(args, "command", None)
573
+ if getattr(args, "dry_run", False) or command == "hosts":
574
+ return True
575
+ if command == "project" and getattr(args, "project_action", None) == "show":
576
+ return True
572
577
  if command == "completion":
573
578
  # Shell setup must be observationally read-only: emitting a script must
574
579
  # not create a project log merely because it was run from a repository.
@@ -599,14 +604,8 @@ def _defer_command_logging_until_authorized(args: argparse.Namespace) -> bool:
599
604
  and not getattr(args, "yes", False)
600
605
  )
601
606
  if command == "engine":
602
- forwarded = list(getattr(args, "engine_args", []) or [])
603
- if forwarded and forwarded[0] == "--":
604
- forwarded = forwarded[1:]
605
- # 裸 ``bugx engine`` 会被 command_engine 默认成 status,是真实调度,
606
- # 必须留日志;只有转发里出现帮助词时引擎才只打印帮助、不碰运行态。
607
- return bool(forwarded) and any(
608
- token in ENGINE_HELP_TOKENS for token in forwarded
609
- )
607
+ # Engine actions own their own logging after argument validation.
608
+ return True
610
609
  return False
611
610
 
612
611
 
@@ -635,9 +634,9 @@ def _ensure_project_readme(root: Path, source: Path) -> None:
635
634
  def _run_script(root: Path, name: str, arguments: list[str], timeout: float | None = None) -> int:
636
635
  """运行 core 脚本并透传退出码。
637
636
 
638
- ``timeout``(P3a):lesson/knowledge/probe/self-audit 类调用传 300 秒,
639
- 防止失控脚本永久挂起;mcp serve 与 mcp-runtime start 需要长驻/直通
640
- stdio,保持 None(不设超时)。
637
+ ``timeout`` 由调用方提供。``bugx probe`` 使用有界的 120 秒默认看护
638
+ (CLI 可显式调整到 1800 秒以内),以防失控脚本永久挂起;mcp serve
639
+ 与 mcp-runtime start 需要长驻/直通 stdio,保持 None(不设超时)。
641
640
  """
642
641
  _ensure_core_importable()
643
642
  try:
@@ -687,6 +686,69 @@ def _run_script(root: Path, name: str, arguments: list[str], timeout: float | No
687
686
  raise CliError(_i18n_exc("common.script_run_failed", f"无法运行 {name}: {exc}", name=name, exc=exc)) from exc
688
687
 
689
688
 
689
+ def _remove_tree_force(path: Path) -> None:
690
+ """Remove an already-validated BugX-owned path despite read-only bits.
691
+
692
+ Windows refuses to unlink read-only files even when their parent directory
693
+ is writable. The helper validates the parent path components before
694
+ changing permissions and never follows symlinks while doing so. Callers
695
+ still remain responsible for the higher-level ownership decision.
696
+ """
697
+ path = Path(path)
698
+ _assert_no_symlink_components(path.parent)
699
+ if path.is_symlink():
700
+ path.unlink(missing_ok=True)
701
+ return
702
+ if path.is_file():
703
+ try:
704
+ path.unlink()
705
+ except PermissionError:
706
+ parent = path.parent
707
+ if not parent.is_symlink():
708
+ os.chmod(parent, stat.S_IMODE(parent.stat().st_mode) | 0o700)
709
+ os.chmod(path, stat.S_IMODE(path.stat().st_mode) | stat.S_IWUSR)
710
+ path.unlink()
711
+ return
712
+ if not path.exists():
713
+ return
714
+
715
+ for current, _directories, files in os.walk(path, topdown=True, followlinks=False):
716
+ current_path = Path(current)
717
+ try:
718
+ os.chmod(current_path, stat.S_IMODE(current_path.stat().st_mode) | 0o700)
719
+ except OSError:
720
+ pass
721
+ for name in files:
722
+ target = current_path / name
723
+ if target.is_symlink():
724
+ continue
725
+ try:
726
+ os.chmod(target, stat.S_IMODE(target.stat().st_mode) | stat.S_IWUSR)
727
+ except OSError:
728
+ pass
729
+
730
+ def _on_error(func, target, _exc): # noqa: ANN001 - stdlib callback signature
731
+ target_path = Path(target)
732
+ try:
733
+ if not target_path.is_symlink():
734
+ os.chmod(
735
+ target_path,
736
+ stat.S_IMODE(target_path.stat().st_mode)
737
+ | (stat.S_IWUSR if target_path.is_file() else 0o700),
738
+ )
739
+ parent = target_path.parent
740
+ if parent != target_path and not parent.is_symlink():
741
+ os.chmod(parent, stat.S_IMODE(parent.stat().st_mode) | 0o700)
742
+ except OSError:
743
+ pass
744
+ func(target)
745
+
746
+ try:
747
+ shutil.rmtree(path, onexc=_on_error)
748
+ except TypeError: # Python < 3.12
749
+ shutil.rmtree(path, onerror=_on_error)
750
+
751
+
690
752
  def _run_script_json(
691
753
  root: Path, name: str, arguments: list[str], timeout: float | None = 300.0,
692
754
  ) -> dict | None:
@@ -753,6 +815,8 @@ def _python_environment(overrides: dict[str, str] | None = None) -> dict[str, st
753
815
  continue
754
816
  environment["PATH"] = os.pathsep.join(entries)
755
817
  environment["PYTHONDONTWRITEBYTECODE"] = "1"
818
+ environment["PYTHONUTF8"] = "1"
819
+ environment["PYTHONIOENCODING"] = "utf-8"
756
820
  if "BUGX_PYTHON" not in environment and sys.executable:
757
821
  environment["BUGX_PYTHON"] = sys.executable
758
822
  if overrides:
@@ -894,11 +958,34 @@ def get_build_id() -> int | None:
894
958
  return None
895
959
 
896
960
 
961
+ def is_dev_mode() -> bool:
962
+ """是否处于 dev / alpha 开发模式。正式版(Stable)返回 False。"""
963
+ if os.environ.get("BUGX_DEV") in ("1", "true", "yes", "on"):
964
+ return True
965
+ env = os.environ.get("BUGX_ENV", "").strip().lower()
966
+ if env in ("dev", "development", "local", "test"):
967
+ return True
968
+ try:
969
+ from core.infra.client_metadata import release_channel, client_marker
970
+ channel = release_channel()
971
+ marker = client_marker()
972
+ if channel != "stable" or marker in ("dev", "alpha"):
973
+ return True
974
+ except Exception:
975
+ pass
976
+ return False
977
+
978
+
897
979
  def get_full_version() -> str:
898
- """返回标准版本与 Build ID 组合字符串,例如 0.1.1+build.627。"""
899
- bid = get_build_id()
900
- if bid is not None:
901
- return f"{__version__}+build.{bid}"
980
+ """返回标准版本展示字符串。
981
+
982
+ 正式版(Stable / Release)输出纯语义版本(如 0.1.3,不带 Build ID);
983
+ 只有 dev / alpha 模式才携带(如 0.1.3+build.1)。
984
+ """
985
+ if is_dev_mode():
986
+ bid = get_build_id()
987
+ if bid is not None:
988
+ return f"{__version__}+build.{bid}"
902
989
  return __version__
903
990
 
904
991
 
@@ -521,6 +521,8 @@ def _claude_app_markers() -> tuple[Path, ...]:
521
521
  relative_paths = (
522
522
  "Claude/Claude.exe",
523
523
  "Programs/Claude/Claude.exe",
524
+ "Program Files/Claude/Claude.exe",
525
+ "Program Files (x86)/Claude/Claude.exe",
524
526
  )
525
527
  for base in bases:
526
528
  markers.extend(base / rel for rel in relative_paths)
@@ -533,6 +535,50 @@ def _claude_app_markers() -> tuple[Path, ...]:
533
535
  return tuple(dict.fromkeys(markers))
534
536
 
535
537
 
538
+ def _kimi_app_markers() -> tuple[Path, ...]:
539
+ """Return well-known Kimi desktop application locations."""
540
+ home = Path.home()
541
+ markers: list[Path] = []
542
+ if platform.system() == "Darwin":
543
+ markers.extend((
544
+ Path("/Applications/Kimi.app"),
545
+ Path("/Applications/Kimi Code.app"),
546
+ home / "Applications" / "Kimi.app",
547
+ home / "Applications" / "Kimi Code.app",
548
+ home / "Library" / "Application Support" / "kimi-desktop",
549
+ home / "Library" / "Application Support" / "Kimi Code",
550
+ ))
551
+ elif platform.system() == "Windows":
552
+ bases = [
553
+ Path(value) for variable in
554
+ ("LOCALAPPDATA", "APPDATA", "PROGRAMFILES", "PROGRAMFILES(X86)")
555
+ if (value := os.environ.get(variable))
556
+ ]
557
+ bases.extend(_windows_drive_roots())
558
+ relative_paths = (
559
+ "Kimi/Kimi.exe",
560
+ "kimi-desktop/Kimi.exe",
561
+ "Kimi Code/Kimi Code.exe",
562
+ "Programs/Kimi/Kimi.exe",
563
+ "Programs/kimi-desktop/Kimi.exe",
564
+ "Programs/Kimi Code/Kimi Code.exe",
565
+ "Program Files/Kimi Code/Kimi Code.exe",
566
+ "Program Files (x86)/Kimi Code/Kimi Code.exe",
567
+ )
568
+ for base in bases:
569
+ markers.extend(base / rel for rel in relative_paths)
570
+ else:
571
+ markers.extend((
572
+ home / ".local" / "share" / "applications" / "kimi.desktop",
573
+ home / ".local" / "share" / "applications" / "kimi-code.desktop",
574
+ Path("/usr/bin/kimi-desktop"),
575
+ Path("/usr/bin/kimi-code"),
576
+ Path("/opt/Kimi/kimi"),
577
+ Path("/opt/Kimi Code/kimi-code"),
578
+ ))
579
+ return tuple(dict.fromkeys(markers))
580
+
581
+
536
582
  def _qoder_app_markers() -> tuple[Path, ...]:
537
583
  """Return well-known Qoder desktop application locations."""
538
584
  home = Path.home()
@@ -619,12 +665,22 @@ def _trea_app_markers() -> tuple[Path, ...]:
619
665
  "Programs/trae/Trae.exe",
620
666
  "Trae/Trae.exe",
621
667
  "trae/Trae.exe",
668
+ "Program Files/Trae/Trae.exe",
669
+ "Program Files (x86)/Trae/Trae.exe",
670
+ "Program Files/trae/Trae.exe",
671
+ "Program Files (x86)/trae/Trae.exe",
622
672
  "Programs/Trae CN/Trae CN.exe",
623
673
  "Programs/Trae CN/trae-cn.exe",
624
674
  "Programs/Trae CN/Trae.exe",
625
675
  "Trae CN/Trae CN.exe",
626
676
  "Trae CN/trae-cn.exe",
627
677
  "Trae CN/Trae.exe",
678
+ "Program Files/Trae CN/Trae CN.exe",
679
+ "Program Files (x86)/Trae CN/Trae CN.exe",
680
+ "Program Files/Trae CN/trae-cn.exe",
681
+ "Program Files (x86)/Trae CN/trae-cn.exe",
682
+ "Program Files/Trae CN/Trae.exe",
683
+ "Program Files (x86)/Trae CN/Trae.exe",
628
684
  )
629
685
  for base in bases:
630
686
  markers.extend(base / rel for rel in relative_paths)
@@ -1202,6 +1258,7 @@ CAP_GLOBAL_AGENT_LINK = "global-agent-link" # 注册用户级全局 age
1202
1258
  CAP_GLOBAL_SKILL_LINK = "global-skill-link" # 注册用户级全局 skill 链接
1203
1259
  CAP_NATIVE_MCP_CONFIG = "native-mcp-config" # 需要写宿主原生项目/工作区 MCP 容器
1204
1260
  CAP_USER_AGENT_REGISTRATION = "user-agent-registration" # 需要用户级子智能体注册
1261
+ CAP_USER_LEVEL_PLUGIN = "user-level-plugin" # 需要写用户级 Plugin V1 包
1205
1262
  CAP_USER_LEVEL_ARTIFACT = "user-level-artifact" # 需要写用户级 Skill / Connector 产物
1206
1263
  CAP_WORKSPACE_MIRROR = "workspace-mirror" # 支持工作区同构镜像(如 Roo Code .roo)
1207
1264
  #: 需要把入口额外镜像到本宿主的**变体目录**(如 Trae 的 .trae / .trae-cn)。
@@ -1213,6 +1270,8 @@ HOST_NAME_ZCODE = "zcode"
1213
1270
  HOST_NAME_CLAUDE = "claude"
1214
1271
  HOST_NAME_QODER = "qoder"
1215
1272
  HOST_NAME_FUNIDE = "funide"
1273
+ HOST_NAME_KIMI = "kimi"
1274
+ HOST_NAME_MINIMAX = "minimax"
1216
1275
 
1217
1276
 
1218
1277
  @dataclass(frozen=True)
@@ -1284,6 +1343,8 @@ class HostAdapter:
1284
1343
  return ["skill", "extension"]
1285
1344
  if self.supports(CAP_DISTRIBUTION_PLUGIN):
1286
1345
  return ["plugin"]
1346
+ if self.supports(CAP_USER_LEVEL_PLUGIN):
1347
+ return ["plugin"]
1287
1348
  return ["entry"]
1288
1349
 
1289
1350
  def detect(self, root: Path) -> dict[str, object]:
@@ -1442,6 +1503,70 @@ class ClaudeAdapter(HostAdapter):
1442
1503
  return _ensure_claude_user_agents(root, source, locale=locale)
1443
1504
 
1444
1505
 
1506
+ class KimiAdapter(HostAdapter):
1507
+ """Kimi Code CLI & Desktop adapter."""
1508
+
1509
+ def _app_markers(self) -> tuple[Path, ...]:
1510
+ return _kimi_app_markers()
1511
+
1512
+ def _user_marker(self) -> bool:
1513
+ configured = os.environ.get("KIMI_CODE_HOME")
1514
+ kimi_home = (
1515
+ Path(configured).expanduser()
1516
+ if configured and configured.strip()
1517
+ else Path.home() / ".kimi-code"
1518
+ )
1519
+ return kimi_home.is_dir()
1520
+
1521
+ def render_required_entry(
1522
+ self, relative: str, source: Path, *, locale: str | None = None,
1523
+ ) -> str | None:
1524
+ if relative.endswith("bugx-worker.md"):
1525
+ return render_claude_worker_entry(locale=locale)
1526
+ return None
1527
+
1528
+ def ensure_user_agents(
1529
+ self, root: Path, source: Path, *, locale: str | None = None,
1530
+ ) -> dict[str, object] | None:
1531
+ from .commands.plugin_kimi import _ensure_kimi_plugin
1532
+ return _ensure_kimi_plugin(root, source, locale=locale)
1533
+
1534
+
1535
+ class MiniMaxAdapter(HostAdapter):
1536
+ """MiniMax Code desktop Plugin V1 adapter."""
1537
+
1538
+ def _app_markers(self) -> tuple[Path, ...]:
1539
+ plugin = engine_host_plugin(self.name)
1540
+ marker_factory = plugin.identity.app_markers
1541
+ return tuple(marker_factory()) if marker_factory is not None else ()
1542
+
1543
+ def _user_marker(self) -> bool:
1544
+ configured = os.environ.get("MINIMAX_DATA_DIR")
1545
+ data_dir = (
1546
+ Path(configured).expanduser()
1547
+ if configured and configured.strip()
1548
+ else Path.home() / ".minimax"
1549
+ )
1550
+ return (
1551
+ data_dir / "plugins" / "bugx" / ".minimax-plugin" / "plugin.json"
1552
+ ).is_file()
1553
+
1554
+ def _project_marker(self, root: Path) -> bool:
1555
+ if self._user_marker():
1556
+ return True
1557
+ return super()._project_marker(root)
1558
+
1559
+ @property
1560
+ def installed_components(self) -> list[str]:
1561
+ return ["plugin", "agent", "worker", "skill", "mcp"]
1562
+
1563
+ def ensure_user_agents(
1564
+ self, root: Path, source: Path, *, locale: str | None = None,
1565
+ ) -> dict[str, object] | None:
1566
+ from .commands.plugin_minimax import _ensure_minimax_plugin
1567
+ return _ensure_minimax_plugin(root, source, locale=locale)
1568
+
1569
+
1445
1570
  class ZCodeAdapter(HostAdapter):
1446
1571
  """ZCode IDE adapter."""
1447
1572
 
@@ -1624,6 +1749,14 @@ class TreaAdapter(HostAdapter):
1624
1749
  info = super().detect(root)
1625
1750
  home = Path.home()
1626
1751
  variants: list[str] = []
1752
+ app_markers = self._app_markers()
1753
+ cn_app_markers = tuple(
1754
+ marker for marker in app_markers
1755
+ if any(token in str(marker).casefold() for token in ("trae cn", "trae-cn"))
1756
+ )
1757
+ global_app_markers = tuple(
1758
+ marker for marker in app_markers if marker not in cn_app_markers
1759
+ )
1627
1760
 
1628
1761
  cn_paths = [
1629
1762
  Path("/Applications/Trae CN.app"),
@@ -1632,7 +1765,11 @@ class TreaAdapter(HostAdapter):
1632
1765
  home / "Library" / "Application Support" / "Trae CN",
1633
1766
  root / ".trae-cn",
1634
1767
  ]
1635
- if shutil.which("trae-cn") or any(p.exists() for p in cn_paths):
1768
+ if (
1769
+ shutil.which("trae-cn")
1770
+ or any(p.exists() for p in cn_paths)
1771
+ or any(p.exists() for p in cn_app_markers)
1772
+ ):
1636
1773
  variants.append("trae-cn")
1637
1774
 
1638
1775
  global_paths = [
@@ -1643,7 +1780,11 @@ class TreaAdapter(HostAdapter):
1643
1780
  root / ".trae",
1644
1781
  root / ".trea",
1645
1782
  ]
1646
- if shutil.which("trae") or any(p.exists() for p in global_paths):
1783
+ if (
1784
+ shutil.which("trae")
1785
+ or any(p.exists() for p in global_paths)
1786
+ or any(p.exists() for p in global_app_markers)
1787
+ ):
1647
1788
  variants.append("trae")
1648
1789
 
1649
1790
  info["detected_variants"] = variants
@@ -1654,8 +1795,9 @@ class TreaAdapter(HostAdapter):
1654
1795
  if cn_exe:
1655
1796
  info["executable"] = cn_exe
1656
1797
  else:
1657
- for marker in self._app_markers():
1658
- if "trae-cn" in marker.name and marker.is_file():
1798
+ for marker in app_markers:
1799
+ marker_name = marker.name.casefold()
1800
+ if ("trae-cn" in marker_name or "trae cn" in marker_name) and marker.is_file():
1659
1801
  info["executable"] = str(marker)
1660
1802
  break
1661
1803
  return info
@@ -1824,6 +1966,10 @@ HOST_ADAPTERS: tuple[HostAdapter, ...] = (
1824
1966
  # ZCodeAdapter 只保留 CLI 侧行为覆写。引擎快照不可用时跳过(见
1825
1967
  # _plugin_backed_adapters:全新机器上必须先能启动 bugx init)。
1826
1968
  *_plugin_backed_adapters(ZCodeAdapter),
1969
+ # DOC-239:声明字段全部来自引擎插件(core/hosts/kimi.py)。
1970
+ *_plugin_backed_adapters(KimiAdapter),
1971
+ # MiniMax Code 桌面端通过 Plugin V1 注册 Agent、Skill 与 MCP。
1972
+ *_plugin_backed_adapters(MiniMaxAdapter),
1827
1973
  WorkBuddyAdapter(
1828
1974
  "workbuddy", "WorkBuddy AI", "workbuddy", ".workbuddy",
1829
1975
  WORKBUDDY_PROJECT_PATHS[0], "skill", WORKBUDDY_PROJECT_PATHS,
@@ -288,7 +288,7 @@ def engine_worker_entry_dir(name: str) -> str:
288
288
  #: 进程池执行器)自动追加,不进本表。这不是第二份宿主事实:宿主身份仍在
289
289
  #: 插件/``SUPPORTED_HOSTS``,本表只说「CLI 的 host 选项按什么顺序出现」。
290
290
  AUTONOMOUS_HOST_BASELINE: tuple[str, ...] = (
291
- "claude", "codex", "opencode", "dsh", "pi",
291
+ "claude", "codex", "opencode", "dsh", "pi", "kimi",
292
292
  )
293
293
 
294
294
 
@@ -375,7 +375,9 @@ def _component_from_plugin(name: str) -> HostComponent:
375
375
  #: 本清单只用于**定位/枚举插件**,不含任何宿主事实(不复制 label、路径、能力)。
376
376
  #: 它随纵切推进增长;全部宿主迁移完成后本清单与 ``HOST_COMPONENTS`` 的本地字面量
377
377
  #: 会一起消失。
378
- PLUGIN_BACKED_HOSTS: tuple[str, ...] = ("cline", "codex", "claude", "pi", "zcode")
378
+ PLUGIN_BACKED_HOSTS: tuple[str, ...] = (
379
+ "cline", "codex", "claude", "pi", "zcode", "kimi", "minimax",
380
+ )
379
381
 
380
382
 
381
383
  def plugin_backed_components() -> tuple[HostComponent, ...]:
@@ -15,25 +15,26 @@ if TYPE_CHECKING:
15
15
 
16
16
  # 宿主入口 frontmatter 触发文案与 Worker 描述
17
17
  AGENT_DESCRIPTION_EN = (
18
- "An autonomous agent dedicated to code review, vulnerability hunting, and automated bug fixing. "
19
- "Built for deep investigations, BugX steps in when you are wrapping up a feature, opening a pull request, or hunting down an elusive bug. "
20
- "It analyzes code logic, automatically writes test cases to uncover and reproduce hidden flaws, and delivers verified patches that resolve root causes. "
21
- "Always safeguarding your code quality and security."
18
+ "An autonomous code review and testing agent designed to safeguard software delivery. "
19
+ "It surfaces hidden bugs for developers to eliminate painful debugging and rework, "
20
+ "while automating black-box, functional, and performance testing across complex edge cases for QA. "
21
+ "Ensures code runs reliably, meets all requirements, and frees engineers to focus on what matters."
22
22
  )
23
23
 
24
24
  AGENT_DESCRIPTION_ZH = (
25
- "专注于代码质量与安全的自主审查智能体。专为深层缺陷排查而生——在功能写完、提 PR 或排查疑难 Bug 时,"
26
- "它能深入分析代码逻辑,自动编写测试用例,挖掘、复现Bug和漏洞,生成经过验证的修复补丁。随时为您的代码质量和代码安全把关。"
25
+ "BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,"
26
+ "减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;"
27
+ "确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。"
27
28
  )
28
29
 
29
30
  BUGX_WORKER_DESCRIPTION_ZH = (
30
- "BugX 并发审查 Worker。由 BugX 主智能体并发调度,负责具体代码模块的深度审查、缺陷挖掘与可复现用例验证;"
31
+ "BugX 并发测试审查 Worker。由 BugX 主智能体并发调度,负责具体代码模块的审查、缺陷排查与自动化测试验证;"
31
32
  "仅作为子智能体工作节点协同运行。"
32
33
  )
33
34
 
34
35
  BUGX_WORKER_DESCRIPTION_EN = (
35
- "A concurrent audit worker dispatched in parallel by the primary BugX agent to inspect assigned modules, "
36
- "hunt vulnerabilities, and verify defect reproduction as a collaborative subagent."
36
+ "A concurrent test and review worker dispatched by BugX to inspect assigned modules, "
37
+ "uncover deep bugs, and run automated verification as a collaborative subagent."
37
38
  )
38
39
 
39
40
  AGENT_DESCRIPTION = AGENT_DESCRIPTION_ZH
@@ -11,6 +11,7 @@ import json
11
11
  import os
12
12
  import re
13
13
  import shutil
14
+ import stat
14
15
  import sys
15
16
  import sysconfig
16
17
  import tempfile
@@ -415,12 +416,22 @@ def _asset_candidates() -> list[Path]:
415
416
  try:
416
417
  resolved = candidate.resolve(strict=True)
417
418
  mode = resolved.stat().st_mode
419
+ # ``st_mode`` permission bits are an authoritative write-safety
420
+ # signal only on POSIX. On Windows Python commonly reports a
421
+ # synthesized directory mode such as ``0o40777``; it does not
422
+ # expose the directory ACL through this field. Applying the
423
+ # POSIX ``0o022`` test there rejects valid npm-installed assets
424
+ # before the package's own integrity and entry checks can run.
425
+ posix_mode_safe = (
426
+ os.name != "posix"
427
+ or not bool(stat.S_IMODE(mode) & 0o022)
428
+ )
418
429
  safe_files = all(
419
430
  (resolved / name).is_file() and not (resolved / name).is_symlink()
420
431
  for name in ("bugx.md", "launch_bugx.py")
421
432
  )
422
433
  if resolved.is_dir() and not candidate.is_symlink() \
423
- and not mode & 0o022 and safe_files:
434
+ and posix_mode_safe and safe_files:
424
435
  candidates.insert(index, resolved)
425
436
  return True
426
437
  except OSError:
@@ -1057,7 +1068,7 @@ def _installed_engine_version(destination: Path) -> str | None:
1057
1068
  except (OSError, ValueError):
1058
1069
  payload = None
1059
1070
  version = payload.get("bugx_version") if isinstance(payload, dict) else None
1060
- if version == "0.1.1":
1071
+ if version == "0.1.3":
1061
1072
  version = os.environ.get("BUGX_VERSION", __version__)
1062
1073
  if isinstance(version, str) and version.strip():
1063
1074
  return _full_engine_version(version.strip(), destination)
@@ -1070,7 +1081,7 @@ def _installed_engine_version(destination: Path) -> str | None:
1070
1081
  match = re.search(r'bugx_version:\s*"([^"]+)"', content)
1071
1082
  if match:
1072
1083
  version = match.group(1)
1073
- if version == "0.1.1":
1084
+ if version == "0.1.3":
1074
1085
  version = os.environ.get("BUGX_VERSION", __version__)
1075
1086
  return _full_engine_version(version, destination)
1076
1087
  return None
@@ -1133,10 +1144,10 @@ def _install_engine(
1133
1144
  and source.resolve() == repository_core.resolve():
1134
1145
  print(
1135
1146
  f"[bugx] 警告:拒绝从项目源码树安装引擎:{source.resolve()};"
1136
- "仅显式 force=True 才允许该开发操作。",
1147
+ "仅显式传入 --force 才允许该开发操作。",
1137
1148
  file=sys.stderr,
1138
1149
  )
1139
- raise CliError("拒绝从项目源码树安装引擎;请确认来源后显式使用 force=True。")
1150
+ raise CliError("拒绝从项目源码树安装引擎;请确认来源后显式使用 --force。")
1140
1151
  if destination is None:
1141
1152
  override = os.environ.get("BUGX_GLOBAL_ENGINE_ROOT")
1142
1153
  raw_destination = (Path(override).expanduser() if override
@@ -1188,16 +1199,16 @@ def _install_engine(
1188
1199
  if installed_build_id is None:
1189
1200
  raise CliError(
1190
1201
  "已安装全局引擎缺少 Build ID 标记(可能损坏或来源未知),拒绝静默覆盖;"
1191
- "如确需覆盖请显式传入 force=True。"
1202
+ "如确需覆盖请显式传入 --force。"
1192
1203
  )
1193
1204
  if source_build_id is None:
1194
1205
  raise CliError(
1195
- "安装源缺少 Build ID 标记,拒绝安装;请检查安装资源或显式传入 force=True。"
1206
+ "安装源缺少 Build ID 标记,拒绝安装;请检查安装资源或显式传入 --force。"
1196
1207
  )
1197
1208
  if installed_build_id > source_build_id:
1198
1209
  raise CliError(
1199
1210
  f"拒绝降级全局引擎:已安装 build_id={installed_build_id},"
1200
- f"安装源 build_id={source_build_id};如确需回退请显式传入 force=True。"
1211
+ f"安装源 build_id={source_build_id};如确需回退请显式传入 --force。"
1201
1212
  )
1202
1213
  expected = _engine_file_manifest(source)
1203
1214
  healthy, detail = _engine_integrity_status(source, destination)
@@ -1790,7 +1801,7 @@ def _version_marker(path: Path, pattern: re.Pattern[str], *, allow_symlink: bool
1790
1801
  except (OSError, UnicodeError, CliError):
1791
1802
  return None
1792
1803
  value = match.group(1) if match else None
1793
- if value == "0.1.1":
1804
+ if value == "0.1.3":
1794
1805
  value = os.environ.get("BUGX_VERSION", __version__)
1795
1806
  return value if value and _CONTRACT_VERSION_RE.fullmatch(value) else None
1796
1807
 
@@ -1804,7 +1815,7 @@ def _json_version_marker(path: Path, key: str) -> str | None:
1804
1815
  except (OSError, UnicodeError, json.JSONDecodeError, CliError):
1805
1816
  return None
1806
1817
  value = payload.get(key) if isinstance(payload, dict) else None
1807
- if value == "0.1.1":
1818
+ if value == "0.1.3":
1808
1819
  value = os.environ.get("BUGX_VERSION", __version__)
1809
1820
  return value if isinstance(value, str) and _CONTRACT_VERSION_RE.fullmatch(value) else None
1810
1821
 
@@ -123,7 +123,7 @@ def _plugin_manifest(
123
123
  if not isinstance(name, str) or not re.fullmatch(r"[a-z][a-z0-9-]{1,63}", name):
124
124
  raise CliError(_i18n_exc("common.plugin_name_invalid", f"插件名称无效: {path}", path=path))
125
125
  version = payload.get("version")
126
- if version == "0.1.1":
126
+ if version == "0.1.3":
127
127
  version = os.environ.get("BUGX_VERSION", __version__)
128
128
  payload["version"] = version
129
129
  if not isinstance(version, str) or not PLUGIN_VERSION_RE.fullmatch(version):
@@ -551,14 +551,14 @@ def _mcp_runtime_doctor_payload(root: Path, runtime_root: Path,
551
551
  from ..common import _python_environment
552
552
  result = subprocess.run(
553
553
  [sys.executable, str(_script(root, "mcp_runtime.py")), *script_args],
554
- cwd=root, capture_output=True, text=True, check=False,
554
+ cwd=root, capture_output=True, encoding="utf-8", errors="replace", check=False,
555
555
  env=_python_environment(), timeout=120,
556
556
  )
557
557
  if result.returncode != 0 and "--fast" in script_args and "unrecognized arguments: --fast" in (result.stderr or ""):
558
558
  script_args_fallback = [a for a in script_args if a != "--fast"]
559
559
  result = subprocess.run(
560
560
  [sys.executable, str(_script(root, "mcp_runtime.py")), *script_args_fallback],
561
- cwd=root, capture_output=True, text=True, check=False,
561
+ cwd=root, capture_output=True, encoding="utf-8", errors="replace", check=False,
562
562
  env=_python_environment(), timeout=120,
563
563
  )
564
564
  try: