bugx-cli 0.1.3 → 0.1.5

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 (167) hide show
  1. package/core/README.md +5 -3
  2. package/core/agent/agent_execution.py +7 -0
  3. package/core/assets/bugx-wechat-group.png +0 -0
  4. package/core/bugx.md +2 -2
  5. package/core/bugx_paths.py +10 -2
  6. package/core/bundled_docs/OVERVIEW.md +311 -0
  7. package/core/bundled_docs/README.md +10 -0
  8. package/core/bundled_docs/README_EN.md +278 -0
  9. package/core/bundled_docs/ai/01_AI_REFERENCE.md +838 -0
  10. package/core/bundled_docs/ai/02_AI_USAGE.md +161 -0
  11. package/core/bundled_docs/ai/03_AI_COMMANDS.md +322 -0
  12. package/core/bundled_docs/guides/01_USER_GUIDE.md +887 -0
  13. package/core/bundled_docs/guides/02_COMMANDS.md +935 -0
  14. package/core/bundled_docs/guides/03_TROUBLESHOOTING.md +763 -0
  15. package/core/bundled_docs/guides/04_CLOUD_AUTH_AND_SYNC_COOKBOOK.md +48 -0
  16. package/core/bundled_docs/guides/05_HOST_MATRIX_AND_DISPATCH.md +25 -0
  17. package/core/bundled_docs/guides/06_PROBES_AND_POC_COOKBOOK.md +49 -0
  18. package/core/bundled_docs/guides/07_LIFECYCLE_AND_RECOVERY_STATES.md +46 -0
  19. package/core/bundled_docs/guides/08_LESSONS_AND_PRIVACY_BOUNDARY.md +35 -0
  20. package/core/bundled_docs/hosts/bugx-claude_SKILL.md +326 -0
  21. package/core/bundled_docs/hosts/bugx-dsh_SKILL.md +229 -0
  22. package/core/bundled_docs/hosts/bugx-opencode_SKILL.md +129 -0
  23. package/core/bundled_docs/hosts/bugx-zcode_SKILL.md +459 -0
  24. package/core/bundled_docs/hosts/bugx_SKILL.md +118 -0
  25. package/core/bundled_docs/hosts/cline_bugx_SKILL.md +69 -0
  26. package/core/bundled_docs/hosts/platform_bugx_SKILL.md +50 -0
  27. package/core/bundled_docs/manifest.json +140 -0
  28. package/core/bundled_docs/reference/01_ENVIRONMENT_VARIABLES.md +422 -0
  29. package/core/bundled_docs/reference/04_REPOSITORY_TOPOLOGY.md +180 -0
  30. package/core/cli-help.txt +7 -3
  31. package/core/cloud_sync/cloud_client.py +81 -2
  32. package/core/cloud_sync/endpoint_router.py +22 -9
  33. package/core/cloud_sync/issue_uploader.py +297 -0
  34. package/core/cloud_sync/sensitive_filter.py +77 -7
  35. package/core/contracts/AGENT_GUIDE.md +3 -9
  36. package/core/contracts/README.md +1 -1
  37. package/core/contracts/bugx-runtime-contract.md +10 -20
  38. package/core/contracts/bugx-worker.md +1 -1
  39. package/core/coverage/coverage_ai_review.py +15 -11
  40. package/core/coverage/coverage_bootstrap.py +18 -13
  41. package/core/coverage/coverage_discovery.py +1 -1
  42. package/core/dev_harness/interaction_preset.py +1 -1
  43. package/core/engine-integrity.json +283 -159
  44. package/core/host_acp/README.md +4 -0
  45. package/core/host_acp/agnescode.py +128 -0
  46. package/core/host_acp/antigravity.py +153 -0
  47. package/core/host_runtime/README.md +3 -0
  48. package/core/host_runtime/adapters.py +5 -1
  49. package/core/host_runtime/antigravity.py +162 -0
  50. package/core/host_runtime/host_bootstrap.py +18 -7
  51. package/core/host_runtime/host_evaluators.py +4 -4
  52. package/core/host_runtime/host_registry.py +3 -1
  53. package/core/host_runtime/mcp_process_tracker.py +30 -3
  54. package/core/host_runtime/mcp_registry_gate.py +34 -11
  55. package/core/hosts/README.md +4 -0
  56. package/core/hosts/agnescode.py +415 -0
  57. package/core/hosts/antigravity.py +115 -0
  58. package/core/hosts/codex.py +3 -0
  59. package/core/hosts/dsh.py +42 -23
  60. package/core/hosts/minimax.py +5 -4
  61. package/core/hosts/opencode.py +11 -3
  62. package/core/i18n.py +94 -5
  63. package/core/infra/README.md +1 -1
  64. package/core/infra/build_info.py +2 -2
  65. package/core/infra/python_runtime.py +4 -1
  66. package/core/launch_phases/README.md +2 -2
  67. package/core/launch_phases/finding_confirm_phase.py +1 -1
  68. package/core/launch_phases/semantic_recon.py +3 -19
  69. package/core/launch_phases/startup_version_gate.py +2 -2
  70. package/core/launch_phases/supervisor_bridge.py +2 -0
  71. package/core/launch_phases/supervisor_degraded.py +7 -5
  72. package/core/launch_phases/verify_loop.py +3 -19
  73. package/core/ledger/README.md +1 -1
  74. package/core/ledger/finding_confirmation.py +1 -1
  75. package/core/ledger/finding_verification.py +2 -20
  76. package/core/ledger/fp_ledger.py +3 -19
  77. package/core/ledger/life_ledger.py +7 -33
  78. package/core/ledger/schema.py +1 -1
  79. package/core/locales/en-US.json +3 -3
  80. package/core/locales/zh-CN.json +3 -3
  81. package/core/mcp_handlers/supervisor_handlers.py +1 -1
  82. package/core/mcp_runtime_support/common.py +6 -0
  83. package/core/mcp_runtime_support/environment.py +88 -24
  84. package/core/metadata.txt +1 -1
  85. package/core/planning/README.md +1 -1
  86. package/core/planning/prompt_harness.py +2 -2
  87. package/core/planning/target_sandbox_manager.py +2 -0
  88. package/core/probes/codebase_memory_probe.py +43 -24
  89. package/core/probes/mobile_probe.py +1 -0
  90. package/core/probes/probe_registry.py +10 -7
  91. package/core/probes/sast_probe.py +1 -1
  92. package/core/probes/sca_scanner.py +1 -1
  93. package/core/project_profiler/constants.py +1 -1
  94. package/core/prompts/command_routing_en.md +6 -5
  95. package/core/prompts/command_routing_zh.md +6 -5
  96. package/core/repair/rsi_rounds.py +3 -0
  97. package/core/repair/self_heal.py +160 -6
  98. package/core/retrieval/README.md +1 -1
  99. package/core/retrieval/symbol_index.py +227 -52
  100. package/core/runtime/README.md +1 -1
  101. package/core/runtime/daemon_runner.py +3 -2
  102. package/core/runtime/project_init.py +1 -1
  103. package/core/runtime/scenario_eval.py +5 -1
  104. package/core/runtime/tool_install_targets.py +12 -2
  105. package/core/skills/README.md +4 -2
  106. package/core/skills/bugx_docs_cloud_sync.py +658 -0
  107. package/core/skills/bugx_docs_mcp_server.py +966 -140
  108. package/core/skills/bugx_mcp_server.py +9 -0
  109. package/core/skills/mcp_session_proof.py +3 -31
  110. package/core/supervisor/README.md +1 -1
  111. package/core/supervisor/finding_commit.py +3 -24
  112. package/core/supervisor/task_scheduler.py +5 -2
  113. package/core/supervisor/worker_execution.py +16 -3
  114. package/core/supervisor/worker_handoff.py +2 -2
  115. package/core/webui/docs_session_service.py +40 -2
  116. package/core/webui/mcp_inspector.py +6 -6
  117. package/ecosystem/integrations/cline/skills/bugx/SKILL.md +46 -46
  118. package/ecosystem/integrations/dsh/agents/bugx.md +2 -1
  119. package/ecosystem/integrations/dsh/mcp/package.json +1 -1
  120. package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +5 -5
  121. package/ecosystem/integrations/dsh/ui/package.json +1 -1
  122. package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +4 -4
  123. package/ecosystem/integrations/opencode/mcp-lock.json +1 -1
  124. package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
  125. package/ecosystem/integrations/pi/skills/bugx/SKILL.md +5 -5
  126. package/ecosystem/integrations/qoder/CONNECTORS.md +11 -23
  127. package/ecosystem/integrations/qoder/connector-meta.json +1 -1
  128. package/ecosystem/integrations/workbuddy/connector-meta.json +1 -1
  129. package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +8 -7
  130. package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +1 -1
  131. package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +1 -1
  132. package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +1 -1
  133. package/ecosystem/plugins/bugx/agents/bugx-worker.md +14 -18
  134. package/ecosystem/plugins/bugx/agents/bugx.md +45 -49
  135. package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +7 -7
  136. package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +2 -2
  137. package/interfaces/cli/bugx_cli/__init__.py +1 -1
  138. package/interfaces/cli/bugx_cli/cli.py +153 -8
  139. package/interfaces/cli/bugx_cli/commands/agent.py +376 -69
  140. package/interfaces/cli/bugx_cli/commands/audit.py +2 -1
  141. package/interfaces/cli/bugx_cli/commands/cloud.py +42 -1
  142. package/interfaces/cli/bugx_cli/commands/doctor.py +650 -223
  143. package/interfaces/cli/bugx_cli/commands/guide.py +143 -0
  144. package/interfaces/cli/bugx_cli/commands/issue.py +262 -0
  145. package/interfaces/cli/bugx_cli/commands/lifecycle.py +56 -26
  146. package/interfaces/cli/bugx_cli/commands/patch.py +5 -1
  147. package/interfaces/cli/bugx_cli/commands/plugin.py +306 -56
  148. package/interfaces/cli/bugx_cli/commands/plugin_antigravity.py +350 -0
  149. package/interfaces/cli/bugx_cli/commands/plugin_claude.py +2 -2
  150. package/interfaces/cli/bugx_cli/commands/plugin_kimi.py +154 -62
  151. package/interfaces/cli/bugx_cli/commands/plugin_minimax.py +308 -108
  152. package/interfaces/cli/bugx_cli/commands/system.py +11 -1
  153. package/interfaces/cli/bugx_cli/common.py +39 -8
  154. package/interfaces/cli/bugx_cli/host_adapters.py +46 -3
  155. package/interfaces/cli/bugx_cli/hosts/registry.py +3 -2
  156. package/interfaces/cli/bugx_cli/hosts/template_engine.py +21 -2
  157. package/interfaces/cli/bugx_cli/infra/__init__.py +4 -0
  158. package/interfaces/cli/bugx_cli/infra/ai_advisor.py +14 -12
  159. package/interfaces/cli/bugx_cli/infra/engine_installer.py +76 -10
  160. package/interfaces/cli/bugx_cli/infra/host_sync.py +66 -1
  161. package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +240 -50
  162. package/package.json +3 -2
  163. package/pyproject.toml +22 -2
  164. package/scripts/sync-version.mjs +1 -1
  165. package/skills/README.md +1 -2
  166. package/skills/platform/bugx/SKILL.md +50 -0
  167. package/skills/platform/bugx-user/SKILL.md +0 -92
@@ -16,7 +16,7 @@ import re
16
16
  import shutil
17
17
  import subprocess
18
18
 
19
- from .hosts.registry import engine_host_plugin
19
+ from .hosts.registry import QODER_PROJECT_MCP_PATHS, engine_host_plugin
20
20
  from .hosts.template_engine import (
21
21
  AGENT_DESCRIPTION,
22
22
  AGENT_DESCRIPTION_EN,
@@ -221,10 +221,17 @@ def add_locale_marker(content: str, locale: str | None) -> str:
221
221
  file. The marker is intentionally placed after that metadata block so it
222
222
  remains an inert HTML comment while preserving host discovery semantics.
223
223
  """
224
- if not locale:
224
+ loc = (locale or "").strip()
225
+ if not loc:
226
+ try:
227
+ import core.i18n as i18n
228
+ loc = i18n.resolve_locale().resolved_locale
229
+ except Exception:
230
+ pass
231
+ if not loc:
225
232
  return content
226
233
  content = strip_locale_marker(content)
227
- normalized = str(locale).strip() or "en-US"
234
+ normalized = loc or "en-US"
228
235
  marker = f"<!-- bugx-locale: {normalized} -->\n"
229
236
  if content.startswith("---\n"):
230
237
  closing = content.find("\n---", 4)
@@ -1401,6 +1408,11 @@ class OpenCodeAdapter(HostAdapter):
1401
1408
  pass
1402
1409
 
1403
1410
 
1411
+ class AgnesCodeAdapter(HostAdapter):
1412
+ """Agnes Code CLI adapter."""
1413
+ pass
1414
+
1415
+
1404
1416
  class CodexAdapter(HostAdapter):
1405
1417
  """Codex CLI adapter(仅 CLI 侧行为覆写)。
1406
1418
 
@@ -1560,6 +1572,11 @@ class MiniMaxAdapter(HostAdapter):
1560
1572
  def installed_components(self) -> list[str]:
1561
1573
  return ["plugin", "agent", "worker", "skill", "mcp"]
1562
1574
 
1575
+ def pre_validate(self, root: Path) -> None:
1576
+ from .commands.plugin_minimax import _minimax_custom_agent_path, _validate_custom_agent
1577
+
1578
+ _validate_custom_agent(_minimax_custom_agent_path())
1579
+
1563
1580
  def ensure_user_agents(
1564
1581
  self, root: Path, source: Path, *, locale: str | None = None,
1565
1582
  ) -> dict[str, object] | None:
@@ -1567,6 +1584,27 @@ class MiniMaxAdapter(HostAdapter):
1567
1584
  return _ensure_minimax_plugin(root, source, locale=locale)
1568
1585
 
1569
1586
 
1587
+ class AntigravityAdapter(HostAdapter):
1588
+ def _user_marker(self) -> bool:
1589
+ return (Path.home() / self.install_path).is_file()
1590
+
1591
+ def pre_validate(self, root: Path) -> None:
1592
+ from .commands.plugin_antigravity import pre_validate
1593
+
1594
+ pre_validate()
1595
+
1596
+ def ensure_user_agents(
1597
+ self, root: Path, source: Path, *, locale: str | None = None,
1598
+ ) -> dict[str, object]:
1599
+ from .commands.plugin_antigravity import install_review_plugin
1600
+
1601
+ return install_review_plugin()
1602
+
1603
+ @property
1604
+ def installed_components(self) -> list[str]:
1605
+ return ["plugin", "agent", "worker", "skill", "workspace-mcp"]
1606
+
1607
+
1570
1608
  class ZCodeAdapter(HostAdapter):
1571
1609
  """ZCode IDE adapter."""
1572
1610
 
@@ -1692,6 +1730,9 @@ class ChatGptAdapter(HostAdapter):
1692
1730
  class QoderAdapter(HostAdapter):
1693
1731
  """Qoder AI adapter."""
1694
1732
 
1733
+ def managed_surfaces(self) -> tuple[str, ...]:
1734
+ return (*super().managed_surfaces(), QODER_PROJECT_MCP_PATHS[0])
1735
+
1695
1736
  def _app_markers(self) -> tuple[Path, ...]:
1696
1737
  return _qoder_app_markers()
1697
1738
 
@@ -1970,6 +2011,8 @@ HOST_ADAPTERS: tuple[HostAdapter, ...] = (
1970
2011
  *_plugin_backed_adapters(KimiAdapter),
1971
2012
  # MiniMax Code 桌面端通过 Plugin V1 注册 Agent、Skill 与 MCP。
1972
2013
  *_plugin_backed_adapters(MiniMaxAdapter),
2014
+ *_plugin_backed_adapters(AntigravityAdapter),
2015
+ *_plugin_backed_adapters(AgnesCodeAdapter),
1973
2016
  WorkBuddyAdapter(
1974
2017
  "workbuddy", "WorkBuddy AI", "workbuddy", ".workbuddy",
1975
2018
  WORKBUDDY_PROJECT_PATHS[0], "skill", WORKBUDDY_PROJECT_PATHS,
@@ -43,6 +43,7 @@ WORKBUDDY_PROJECT_PATHS = (
43
43
  ".workbuddy/skills/bugx/SKILL.md",
44
44
  ".codebuddy/skills/bugx/SKILL.md",
45
45
  )
46
+ QODER_PROJECT_MCP_PATHS = (".mcp.json", ".qoder/settings.json")
46
47
 
47
48
 
48
49
  def _packaged_asset_cores() -> tuple[Path, ...]:
@@ -376,7 +377,7 @@ def _component_from_plugin(name: str) -> HostComponent:
376
377
  #: 它随纵切推进增长;全部宿主迁移完成后本清单与 ``HOST_COMPONENTS`` 的本地字面量
377
378
  #: 会一起消失。
378
379
  PLUGIN_BACKED_HOSTS: tuple[str, ...] = (
379
- "cline", "codex", "claude", "pi", "zcode", "kimi", "minimax",
380
+ "cline", "codex", "claude", "pi", "zcode", "kimi", "minimax", "antigravity", "agnescode",
380
381
  )
381
382
 
382
383
 
@@ -503,7 +504,7 @@ HOST_COMPONENTS: tuple[HostComponent, ...] = (
503
504
  single_select="等价于 multiple=false",
504
505
  failure="控件失败时停在当前 gate",
505
506
  ),
506
- mcp=McpContract(config_relpaths=(".qoder/mcp.json", ".mcp.json")),
507
+ mcp=McpContract(config_relpaths=QODER_PROJECT_MCP_PATHS),
507
508
  execution=ExecutionContract(supports_headless=True, host_surface="tui"),
508
509
  aliases=("qoder-cli", "ali-qoder"),
509
510
  capabilities=frozenset({
@@ -44,6 +44,12 @@ BUGX_WORKER_DESCRIPTION = BUGX_WORKER_DESCRIPTION_ZH
44
44
  def get_agent_description(locale: str | None = None) -> str:
45
45
  """Return the localized host agent description (fallback to en-US)."""
46
46
  loc = (locale or "").strip()
47
+ if not loc:
48
+ try:
49
+ import core.i18n as i18n
50
+ loc = i18n.resolve_locale().resolved_locale
51
+ except Exception:
52
+ pass
47
53
  if loc.startswith("zh"):
48
54
  return AGENT_DESCRIPTION_ZH
49
55
  return AGENT_DESCRIPTION_EN
@@ -52,6 +58,12 @@ def get_agent_description(locale: str | None = None) -> str:
52
58
  def get_worker_description(locale: str | None = None) -> str:
53
59
  """Return the localized concurrent worker description (fallback to en-US)."""
54
60
  loc = (locale or "").strip()
61
+ if not loc:
62
+ try:
63
+ import core.i18n as i18n
64
+ loc = i18n.resolve_locale().resolved_locale
65
+ except Exception:
66
+ pass
55
67
  if loc.startswith("zh"):
56
68
  return BUGX_WORKER_DESCRIPTION_ZH
57
69
  return BUGX_WORKER_DESCRIPTION_EN
@@ -59,9 +71,16 @@ def get_worker_description(locale: str | None = None) -> str:
59
71
 
60
72
  def add_locale_marker(content: str, locale: str | None) -> str:
61
73
  """Record the selected locale without invalidating YAML frontmatter."""
62
- if not locale:
74
+ loc = (locale or "").strip()
75
+ if not loc:
76
+ try:
77
+ import core.i18n as i18n
78
+ loc = i18n.resolve_locale().resolved_locale
79
+ except Exception:
80
+ pass
81
+ if not loc:
63
82
  return content
64
- normalized = str(locale).strip() or "en-US"
83
+ normalized = loc or "en-US"
65
84
  marker = f"<!-- bugx-locale: {normalized} -->\n"
66
85
  if content.startswith("---\n"):
67
86
  closing = content.find("\n---", 4)
@@ -39,6 +39,8 @@ from .engine_installer import (
39
39
  _write_engine_integrity,
40
40
  _ensure_global_cli_symlinks,
41
41
  _find_current_cli_executable,
42
+ _global_bugx_dir,
43
+ _is_global_home_scope,
42
44
  asset_root,
43
45
  global_engine_root,
44
46
  project_core,
@@ -187,6 +189,8 @@ __all__ = [
187
189
  "_stage_engine",
188
190
  "verify_builtin_mcp_manifest",
189
191
  "_version_contract_status",
192
+ "_global_bugx_dir",
193
+ "_is_global_home_scope",
190
194
  "_version_marker",
191
195
  "_write_engine_integrity",
192
196
  "_write_host_resource",
@@ -431,12 +431,12 @@ class DiagnosticAIArbitrator:
431
431
  (
432
432
  r"(?:全局引擎完整性|引擎副本一致性)",
433
433
  "全局引擎代码清单 (engine-integrity.json) 哈希不匹配或文件缺失,存在版本漂移或代码被意外修改。",
434
- "`bugx doctor --repair` 在两种情况下会重放安装资源修好引擎:(1) 安装资源 Build ID 严格高于全局引擎;(2) 同 Build ID 且安装资源自身完好。仅当资源自身也损坏(或需要降级)时才会拒绝,此时请重装 CLI。",
434
+ "`bugx doctor --repair` 在两种情况下会重放安装资源修好引擎:(1) 安装资源版本严格高于全局引擎;(2) 同版本且安装资源自身完好。仅当资源自身也损坏(或需要降级)时才会拒绝,此时请重装 CLI。",
435
435
  ),
436
436
  (
437
437
  r"BugX 版本一致性",
438
438
  "CLI 命令入口与全局引擎、镜像清单版本声明不一致,存在环境版本漂移。",
439
- "运行 `bugx doctor --repair` 前先确认安装资源 Build ID 严格高于全局引擎;不满足时升级 CLI wheel 后重试。",
439
+ "运行 `bugx doctor --repair` 前先确认安装资源版本高于或等于全局引擎;不满足时升级 CLI wheel 后重试。",
440
440
  ),
441
441
  (
442
442
  r"项目初始化状态",
@@ -466,13 +466,13 @@ class DiagnosticAIArbitrator:
466
466
  ),
467
467
  (
468
468
  r"MCP 离线 runtime",
469
- "本地离线 MCP 运行时沙箱未建立或环境依赖缺失,导致离线代码工具链不可用。",
470
- "按需运行 `bugx system mcp-runtime install` 建立隔离运行时;这不是 `bugx doctor --repair` 的修复项。",
469
+ "按需构建的本地离线 MCP 运行时沙箱缺失或已损坏。",
470
+ "如需使用需沙箱的扩展 MCP,运行 `bugx mcp-runtime install`(可选按项目启用;这不是全局必需项)。",
471
471
  ),
472
472
  (
473
473
  r"MCP 会话进程卫生",
474
- "检测到系统中存在失控或遗留的 MCP 僵尸进程,可能持续占用端口与系统句柄。",
475
- "运行 bugx system mcp-runtime clean 清理遗留僵尸进程。",
474
+ "同项目 MCP 会话进程数量过多或存在失去父进程的遗弃会话,可能持续占用句柄与资源。",
475
+ "运行 `bugx mcp prune --root <ROOT> --yes` 清理遗留或失联的 MCP 会话进程。",
476
476
  ),
477
477
  (
478
478
  r"BugX CLI 路径",
@@ -485,14 +485,14 @@ class DiagnosticAIArbitrator:
485
485
  "可使用包管理器安装对应外部工具(如 brew install ast-grep ripgrep)提升大规模审计速度。",
486
486
  ),
487
487
  (
488
- r"Tree-sitter 多语言增强",
489
- "未检测到 tree-sitter-language-pack 库,跨语言语法树深度解析回退至词法模式。",
490
- "运行 `bugx doctor --repair` 可尝试安装 `tree-sitter-language-pack`;安装失败时请按错误详情检查 Python 环境和网络。",
488
+ r"Tree-sitter (?:多语言增强|语法解析引擎)",
489
+ "未检测到 `tree-sitter-language-pack==1.14.3` 核心依赖,无法执行跨语言 AST 深度解析。",
490
+ "这是 BugX 全局必需核心依赖,请运行 `bugx doctor --repair --root <ROOT>` 或 `bugx install` 自动安装修复。",
491
491
  ),
492
492
  (
493
- r"codebase-memory 推荐加速",
494
- "知识图谱组件 codebase-memory 未就绪或未启动,当前运行于基础模式。",
495
- "这是可选加速组件;检查插件安装与索引状态,基础模式仍可运行。",
493
+ r"codebase-memory(?: 代码图谱| 推荐加速)?",
494
+ "核心语义图谱组件 `codebase-memory-mcp==0.12.1` 未安装或不可用(不可降级放行)。",
495
+ "这是 BugX 全局必需核心依赖,请运行 `bugx doctor --repair --root <ROOT>` 或 `bugx install` 自动安装修复。",
496
496
  ),
497
497
  (
498
498
  r"UI 视觉与浏览器挖掘环境(?:(可选))?",
@@ -512,6 +512,8 @@ class DiagnosticAIArbitrator:
512
512
  "全局引擎完整性",
513
513
  "BugX 版本一致性",
514
514
  "Tree-sitter 多语言增强",
515
+ "Tree-sitter 语法解析引擎",
516
+ "codebase-memory 代码图谱",
515
517
  })
516
518
 
517
519
  def __init__(self, root: Path) -> None:
@@ -307,6 +307,38 @@ def global_engine_root() -> Path:
307
307
  return (Path.home() / ".bugx" / "core").resolve()
308
308
 
309
309
 
310
+ def _global_bugx_dir() -> Path:
311
+ """Return the user-global ~/.bugx state directory."""
312
+ try:
313
+ return (Path.home() / ".bugx").resolve()
314
+ except OSError:
315
+ return Path.home() / ".bugx"
316
+
317
+
318
+ def _is_global_home_scope(root: Path | None) -> bool:
319
+ """Return True when root targets user-global home scope rather than a project."""
320
+ if root is None:
321
+ return True
322
+ try:
323
+ resolved = root.expanduser().resolve()
324
+ except OSError:
325
+ resolved = root.expanduser()
326
+ try:
327
+ home_resolved = Path.home().resolve()
328
+ except OSError:
329
+ home_resolved = Path.home()
330
+ if resolved == home_resolved:
331
+ return True
332
+ dev_mode = os.environ.get("BUGX_DEV_MODE", "").strip().lower() in {"1", "true", "yes"}
333
+ if not dev_mode:
334
+ try:
335
+ if (resolved / ".bugx").resolve() == _global_bugx_dir():
336
+ return True
337
+ except OSError:
338
+ pass
339
+ return False
340
+
341
+
310
342
  def refresh_i18n_after_engine_swap() -> None:
311
343
  """引擎 staging 换血后热重载 i18n(宿主镜像渲染正确性的前提)。
312
344
 
@@ -330,8 +362,12 @@ def refresh_i18n_after_engine_swap() -> None:
330
362
 
331
363
  def _legacy_project_core_present(root: Path) -> bool:
332
364
  """Return whether a project still exposes the removed executable surface."""
365
+ if _is_global_home_scope(root):
366
+ return False
333
367
  legacy = project_core(root)
334
368
  try:
369
+ if not _is_reparse_point(legacy) and legacy.resolve() == global_engine_root().resolve():
370
+ return False
335
371
  return _is_reparse_point(legacy) or legacy.exists()
336
372
  except OSError:
337
373
  return True
@@ -408,9 +444,14 @@ def _distribution_located_path(located: object) -> Path | None:
408
444
 
409
445
  def _asset_candidates() -> list[Path]:
410
446
  repository_root = _source_checkout_root()
411
- candidates: list[Path] = [
412
- Path(sysconfig.get_path("data")) / "share" / "bugx-agent" / "core",
413
- ]
447
+ # Prefer the data files owned by the distribution that supplied this CLI.
448
+ # On Windows a user-site wheel can coexist with an older system-site
449
+ # ``sysconfig.get_path("data")/share/bugx-agent`` tree. Looking at the
450
+ # system path first silently selects that stale engine and makes a current
451
+ # CLI appear to be a downgrade. The distribution record is the closest
452
+ # trustworthy match for the imported CLI; the system path remains a
453
+ # fallback for legacy/global installs.
454
+ candidates: list[Path] = []
414
455
 
415
456
  def add_secure_candidate(candidate: Path, *, index: int = 0) -> bool:
416
457
  try:
@@ -455,6 +496,9 @@ def _asset_candidates() -> list[Path]:
455
496
  candidates.append(located.parent)
456
497
  except importlib.metadata.PackageNotFoundError:
457
498
  pass
499
+ candidates.append(
500
+ Path(sysconfig.get_path("data")) / "share" / "bugx-agent" / "core",
501
+ )
458
502
  # Checkout assets are deliberately absent by default. The explicit
459
503
  # BUGX_DEV_ASSET_ROOT=1 branch above is the only source-tree opt-in.
460
504
  return list(dict.fromkeys(path.resolve() for path in candidates))
@@ -1068,7 +1112,7 @@ def _installed_engine_version(destination: Path) -> str | None:
1068
1112
  except (OSError, ValueError):
1069
1113
  payload = None
1070
1114
  version = payload.get("bugx_version") if isinstance(payload, dict) else None
1071
- if version == "0.1.3":
1115
+ if version == "0.1.5":
1072
1116
  version = os.environ.get("BUGX_VERSION", __version__)
1073
1117
  if isinstance(version, str) and version.strip():
1074
1118
  return _full_engine_version(version.strip(), destination)
@@ -1081,7 +1125,7 @@ def _installed_engine_version(destination: Path) -> str | None:
1081
1125
  match = re.search(r'bugx_version:\s*"([^"]+)"', content)
1082
1126
  if match:
1083
1127
  version = match.group(1)
1084
- if version == "0.1.3":
1128
+ if version == "0.1.5":
1085
1129
  version = os.environ.get("BUGX_VERSION", __version__)
1086
1130
  return _full_engine_version(version, destination)
1087
1131
  return None
@@ -1195,6 +1239,8 @@ def _install_engine(
1195
1239
  destination_nonempty = True
1196
1240
  elif destination.exists() or destination.is_symlink():
1197
1241
  destination_nonempty = True
1242
+ installed_version = _installed_engine_version(destination)
1243
+ source_version = _full_engine_version(__version__, source)
1198
1244
  if not force and destination_nonempty:
1199
1245
  if installed_build_id is None:
1200
1246
  raise CliError(
@@ -1205,10 +1251,23 @@ def _install_engine(
1205
1251
  raise CliError(
1206
1252
  "安装源缺少 Build ID 标记,拒绝安装;请检查安装资源或显式传入 --force。"
1207
1253
  )
1208
- if installed_build_id > source_build_id:
1254
+ is_downgrade = _is_newer_version(installed_version, source_version or __version__)
1255
+ if not is_downgrade and (installed_version is None or source_version is None):
1256
+ if installed_build_id > source_build_id:
1257
+ is_downgrade = True
1258
+ if is_downgrade:
1259
+ self_ok, detail = _engine_self_integrity(destination)
1260
+ if self_ok:
1261
+ print(
1262
+ f"[engine] 已跳过引擎替换:已安装 {installed_version or f'build_id={installed_build_id}'} 比当前 CLI "
1263
+ f"{source_version or __version__} 更新且自身完整({detail});如需强制回退请追加 --force",
1264
+ file=sys.stderr,
1265
+ )
1266
+ return 0, 0
1209
1267
  raise CliError(
1210
- f"拒绝降级全局引擎:已安装 build_id={installed_build_id},"
1211
- f"安装源 build_id={source_build_id};如确需回退请显式传入 --force。"
1268
+ f"拒绝降级全局引擎:已安装版本 {installed_version or f'build_id={installed_build_id}'} "
1269
+ f"高于当前安装源 {source_version or f'build_id={source_build_id}'},且完整性校验失败({detail});"
1270
+ "如确需回退请显式传入 --force。"
1212
1271
  )
1213
1272
  expected = _engine_file_manifest(source)
1214
1273
  healthy, detail = _engine_integrity_status(source, destination)
@@ -1514,6 +1573,13 @@ def _engine_roots() -> list[Path]:
1514
1573
  bundled = asset_root()
1515
1574
  except CliError:
1516
1575
  bundled = None
1576
+ if bundled is None:
1577
+ try:
1578
+ repo_core = _source_checkout_root() / "core"
1579
+ if repo_core.is_dir() and (repo_core / "launch_bugx.py").is_file():
1580
+ bundled = repo_core
1581
+ except Exception:
1582
+ pass
1517
1583
  if bundled is not None and bundled.is_dir() and bundled not in roots:
1518
1584
  roots.append(bundled)
1519
1585
  return roots
@@ -1801,7 +1867,7 @@ def _version_marker(path: Path, pattern: re.Pattern[str], *, allow_symlink: bool
1801
1867
  except (OSError, UnicodeError, CliError):
1802
1868
  return None
1803
1869
  value = match.group(1) if match else None
1804
- if value == "0.1.3":
1870
+ if value == "0.1.5":
1805
1871
  value = os.environ.get("BUGX_VERSION", __version__)
1806
1872
  return value if value and _CONTRACT_VERSION_RE.fullmatch(value) else None
1807
1873
 
@@ -1815,7 +1881,7 @@ def _json_version_marker(path: Path, key: str) -> str | None:
1815
1881
  except (OSError, UnicodeError, json.JSONDecodeError, CliError):
1816
1882
  return None
1817
1883
  value = payload.get(key) if isinstance(payload, dict) else None
1818
- if value == "0.1.3":
1884
+ if value == "0.1.5":
1819
1885
  value = os.environ.get("BUGX_VERSION", __version__)
1820
1886
  return value if isinstance(value, str) and _CONTRACT_VERSION_RE.fullmatch(value) else None
1821
1887
 
@@ -86,6 +86,48 @@ def pi_skill_root() -> Path:
86
86
  raise CliError(_i18n_exc("common.pi_skill_missing", "找不到 Pi BugX Skill 资源;请重新安装 BugX"))
87
87
 
88
88
 
89
+ def find_bugx_skill_source(root: Path, source: Path) -> Path | None:
90
+ """Locate a shipped or repository BugX SKILL.md without hardcoding checkout layout."""
91
+ repo_root = _find_repo_root(Path(__file__))
92
+ candidates: list[Path] = [
93
+ source / "skills" / "platform" / "bugx" / "SKILL.md",
94
+ source / "skills" / "bugx" / "SKILL.md",
95
+ source / "plugins" / "bugx" / "skills" / "bugx" / "SKILL.md",
96
+ source / "ecosystem" / "plugins" / "bugx" / "skills" / "bugx" / "SKILL.md",
97
+ source.parent / "skills" / "platform" / "bugx" / "SKILL.md",
98
+ source.parent / "skills" / "bugx" / "SKILL.md",
99
+ source.parent / "plugins" / "bugx" / "skills" / "bugx" / "SKILL.md",
100
+ source.parent / "ecosystem" / "plugins" / "bugx" / "skills" / "bugx" / "SKILL.md",
101
+ root / "plugins" / "bugx" / "skills" / "bugx" / "SKILL.md",
102
+ root / "ecosystem" / "plugins" / "bugx" / "skills" / "bugx" / "SKILL.md",
103
+ global_engine_root() / "skills" / "bugx" / "SKILL.md",
104
+ Path(sysconfig.get_path("data")) / "share" / "bugx-agent" / "skills" / "platform" / "bugx" / "SKILL.md",
105
+ repo_root / "skills" / "platform" / "bugx" / "SKILL.md",
106
+ repo_root / "ecosystem" / "plugins" / "bugx" / "skills" / "bugx" / "SKILL.md",
107
+ ]
108
+ try:
109
+ distribution = importlib.metadata.distribution("bugx-cli")
110
+ for item in distribution.files or []:
111
+ text = item.as_posix()
112
+ if text.endswith((
113
+ "share/bugx-agent/skills/platform/bugx/SKILL.md",
114
+ "share/bugx-agent/pi/skills/bugx/SKILL.md",
115
+ )):
116
+ located = _distribution_located_path(distribution.locate_file(item))
117
+ if located is not None:
118
+ candidates.append(located)
119
+ except importlib.metadata.PackageNotFoundError:
120
+ pass
121
+ try:
122
+ candidates.append(pi_skill_root() / "SKILL.md")
123
+ except CliError:
124
+ pass
125
+ for candidate in dict.fromkeys(candidates):
126
+ if not candidate.is_symlink() and candidate.is_file():
127
+ return candidate
128
+ return None
129
+
130
+
89
131
  def _copy_pi_extension(root: Path, force: bool) -> tuple[int, int, list[Path]]:
90
132
  """Install the complete Pi extension bundle as static project resources."""
91
133
  source = pi_extension_root()
@@ -123,7 +165,7 @@ def _plugin_manifest(
123
165
  if not isinstance(name, str) or not re.fullmatch(r"[a-z][a-z0-9-]{1,63}", name):
124
166
  raise CliError(_i18n_exc("common.plugin_name_invalid", f"插件名称无效: {path}", path=path))
125
167
  version = payload.get("version")
126
- if version == "0.1.3":
168
+ if version == "0.1.5":
127
169
  version = os.environ.get("BUGX_VERSION", __version__)
128
170
  payload["version"] = version
129
171
  if not isinstance(version, str) or not PLUGIN_VERSION_RE.fullmatch(version):
@@ -441,6 +483,29 @@ def _host_bundle_checks(root: Path, target_hosts: set[str] | None = None) -> tup
441
483
  path for path in required
442
484
  if not safe_file(path)
443
485
  ]
486
+ elif adapter.name == "antigravity":
487
+ # Antigravity deliberately splits its surfaces: the Agent,
488
+ # Worker and Skill are registered in the user-level plugin, while
489
+ # only the workspace MCP file belongs under the project root.
490
+ # Do not apply the generic project-relative ``install_path``
491
+ # check; it would turn ``.gemini/...`` into a false missing entry.
492
+ from ..commands.plugin_antigravity import validate_install
493
+
494
+ valid, detail = validate_install(root)
495
+ checks.append((f"{adapter.label} 完整适配包", valid, detail))
496
+ continue
497
+ elif adapter.name == "minimax":
498
+ from ..commands.plugin_minimax import validate_install as _validate_minimax
499
+
500
+ ok_mm, detail_mm = _validate_minimax(root)
501
+ checks.append((f"{adapter.label} 完整适配包", ok_mm, detail_mm))
502
+ continue
503
+ elif adapter.name == "kimi":
504
+ from ..commands.plugin_kimi import validate_install as _validate_kimi
505
+
506
+ ok_km, detail_km = _validate_kimi(root)
507
+ checks.append((f"{adapter.label} 完整适配包", ok_km, detail_km))
508
+ continue
444
509
  else:
445
510
  target_path = root / adapter.install_path
446
511
  if not target_path.exists() and not target_path.is_symlink():