bugx-cli 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/README.md +5 -3
- package/core/assets/bugx-wechat-group.png +0 -0
- package/core/bugx.md +2 -2
- package/core/bugx_paths.py +10 -2
- package/core/bundled_docs/OVERVIEW.md +310 -0
- package/core/bundled_docs/README.md +10 -0
- package/core/bundled_docs/README_EN.md +278 -0
- package/core/bundled_docs/ai/01_AI_REFERENCE.md +833 -0
- package/core/bundled_docs/ai/02_AI_USAGE.md +161 -0
- package/core/bundled_docs/ai/03_AI_COMMANDS.md +322 -0
- package/core/bundled_docs/guides/01_USER_GUIDE.md +887 -0
- package/core/bundled_docs/guides/02_COMMANDS.md +935 -0
- package/core/bundled_docs/guides/03_TROUBLESHOOTING.md +763 -0
- package/core/bundled_docs/guides/04_CLOUD_AUTH_AND_SYNC_COOKBOOK.md +48 -0
- package/core/bundled_docs/guides/05_HOST_MATRIX_AND_DISPATCH.md +23 -0
- package/core/bundled_docs/guides/06_PROBES_AND_POC_COOKBOOK.md +49 -0
- package/core/bundled_docs/guides/07_LIFECYCLE_AND_RECOVERY_STATES.md +46 -0
- package/core/bundled_docs/guides/08_LESSONS_AND_PRIVACY_BOUNDARY.md +35 -0
- package/core/bundled_docs/hosts/bugx-claude_SKILL.md +326 -0
- package/core/bundled_docs/hosts/bugx-dsh_SKILL.md +229 -0
- package/core/bundled_docs/hosts/bugx-opencode_SKILL.md +129 -0
- package/core/bundled_docs/hosts/bugx-zcode_SKILL.md +459 -0
- package/core/bundled_docs/hosts/bugx_SKILL.md +118 -0
- package/core/bundled_docs/hosts/cline_bugx_SKILL.md +69 -0
- package/core/bundled_docs/hosts/platform_bugx_SKILL.md +50 -0
- package/core/bundled_docs/manifest.json +140 -0
- package/core/bundled_docs/reference/01_ENVIRONMENT_VARIABLES.md +421 -0
- package/core/bundled_docs/reference/04_REPOSITORY_TOPOLOGY.md +180 -0
- package/core/cli-help.txt +7 -3
- package/core/cloud_sync/cloud_client.py +81 -2
- package/core/cloud_sync/endpoint_router.py +22 -9
- package/core/cloud_sync/issue_uploader.py +297 -0
- package/core/cloud_sync/sensitive_filter.py +77 -7
- package/core/contracts/AGENT_GUIDE.md +3 -9
- package/core/contracts/README.md +1 -1
- package/core/contracts/bugx-runtime-contract.md +10 -20
- package/core/contracts/bugx-worker.md +1 -1
- package/core/engine-integrity.json +209 -93
- package/core/host_acp/antigravity.py +153 -0
- package/core/host_runtime/adapters.py +5 -1
- package/core/host_runtime/antigravity.py +162 -0
- package/core/host_runtime/host_bootstrap.py +18 -7
- package/core/host_runtime/host_evaluators.py +4 -4
- package/core/host_runtime/host_registry.py +2 -1
- package/core/host_runtime/mcp_process_tracker.py +30 -3
- package/core/host_runtime/mcp_registry_gate.py +34 -11
- package/core/hosts/antigravity.py +115 -0
- package/core/hosts/codex.py +3 -0
- package/core/hosts/dsh.py +42 -23
- package/core/hosts/minimax.py +5 -4
- package/core/i18n.py +94 -5
- package/core/infra/README.md +1 -1
- package/core/infra/build_info.py +2 -2
- package/core/launch_phases/README.md +2 -2
- package/core/launch_phases/startup_version_gate.py +2 -2
- package/core/launch_phases/supervisor_bridge.py +2 -0
- package/core/launch_phases/supervisor_degraded.py +7 -5
- package/core/ledger/README.md +1 -1
- package/core/locales/en-US.json +3 -3
- package/core/locales/zh-CN.json +3 -3
- package/core/mcp_runtime_support/environment.py +6 -1
- package/core/metadata.txt +1 -1
- package/core/planning/README.md +1 -1
- package/core/planning/prompt_harness.py +2 -2
- package/core/probes/codebase_memory_probe.py +43 -24
- package/core/probes/probe_registry.py +10 -7
- package/core/prompts/command_routing_en.md +6 -5
- package/core/prompts/command_routing_zh.md +6 -5
- package/core/repair/rsi_rounds.py +3 -0
- package/core/repair/self_heal.py +160 -6
- package/core/retrieval/README.md +1 -1
- package/core/runtime/README.md +1 -1
- package/core/runtime/scenario_eval.py +5 -1
- package/core/runtime/tool_install_targets.py +12 -2
- package/core/skills/README.md +4 -2
- package/core/skills/bugx_docs_cloud_sync.py +658 -0
- package/core/skills/bugx_docs_mcp_server.py +966 -140
- package/core/supervisor/README.md +1 -1
- package/core/supervisor/worker_execution.py +16 -3
- package/core/webui/docs_session_service.py +40 -2
- package/core/webui/mcp_inspector.py +6 -6
- package/ecosystem/integrations/cline/skills/bugx/SKILL.md +46 -46
- package/ecosystem/integrations/dsh/agents/bugx.md +2 -1
- package/ecosystem/integrations/dsh/mcp/package.json +1 -1
- package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +5 -5
- package/ecosystem/integrations/dsh/ui/package.json +1 -1
- package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +2 -2
- package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
- package/ecosystem/integrations/pi/skills/bugx/SKILL.md +5 -5
- package/ecosystem/integrations/qoder/CONNECTORS.md +11 -23
- package/ecosystem/integrations/qoder/connector-meta.json +1 -1
- package/ecosystem/integrations/workbuddy/connector-meta.json +1 -1
- package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +8 -7
- package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +1 -1
- package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +1 -1
- package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +1 -1
- package/ecosystem/plugins/bugx/agents/bugx-worker.md +14 -18
- package/ecosystem/plugins/bugx/agents/bugx.md +45 -49
- package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +7 -7
- package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +2 -2
- package/interfaces/cli/bugx_cli/__init__.py +1 -1
- package/interfaces/cli/bugx_cli/cli.py +138 -8
- package/interfaces/cli/bugx_cli/commands/agent.py +376 -69
- package/interfaces/cli/bugx_cli/commands/cloud.py +42 -1
- package/interfaces/cli/bugx_cli/commands/doctor.py +650 -223
- package/interfaces/cli/bugx_cli/commands/guide.py +143 -0
- package/interfaces/cli/bugx_cli/commands/issue.py +262 -0
- package/interfaces/cli/bugx_cli/commands/lifecycle.py +55 -25
- package/interfaces/cli/bugx_cli/commands/plugin.py +295 -54
- package/interfaces/cli/bugx_cli/commands/plugin_antigravity.py +350 -0
- package/interfaces/cli/bugx_cli/commands/plugin_claude.py +2 -2
- package/interfaces/cli/bugx_cli/commands/plugin_kimi.py +154 -62
- package/interfaces/cli/bugx_cli/commands/plugin_minimax.py +308 -108
- package/interfaces/cli/bugx_cli/commands/system.py +11 -1
- package/interfaces/cli/bugx_cli/common.py +39 -8
- package/interfaces/cli/bugx_cli/host_adapters.py +40 -3
- package/interfaces/cli/bugx_cli/hosts/registry.py +3 -2
- package/interfaces/cli/bugx_cli/hosts/template_engine.py +21 -2
- package/interfaces/cli/bugx_cli/infra/__init__.py +4 -0
- package/interfaces/cli/bugx_cli/infra/ai_advisor.py +14 -12
- package/interfaces/cli/bugx_cli/infra/engine_installer.py +76 -10
- package/interfaces/cli/bugx_cli/infra/host_sync.py +66 -1
- package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +240 -50
- package/package.json +3 -2
- package/pyproject.toml +22 -2
- package/scripts/sync-version.mjs +1 -1
- package/skills/README.md +1 -2
- package/skills/platform/bugx/SKILL.md +50 -0
- 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
|
-
|
|
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 =
|
|
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)
|
|
@@ -1560,6 +1567,11 @@ class MiniMaxAdapter(HostAdapter):
|
|
|
1560
1567
|
def installed_components(self) -> list[str]:
|
|
1561
1568
|
return ["plugin", "agent", "worker", "skill", "mcp"]
|
|
1562
1569
|
|
|
1570
|
+
def pre_validate(self, root: Path) -> None:
|
|
1571
|
+
from .commands.plugin_minimax import _minimax_custom_agent_path, _validate_custom_agent
|
|
1572
|
+
|
|
1573
|
+
_validate_custom_agent(_minimax_custom_agent_path())
|
|
1574
|
+
|
|
1563
1575
|
def ensure_user_agents(
|
|
1564
1576
|
self, root: Path, source: Path, *, locale: str | None = None,
|
|
1565
1577
|
) -> dict[str, object] | None:
|
|
@@ -1567,6 +1579,27 @@ class MiniMaxAdapter(HostAdapter):
|
|
|
1567
1579
|
return _ensure_minimax_plugin(root, source, locale=locale)
|
|
1568
1580
|
|
|
1569
1581
|
|
|
1582
|
+
class AntigravityAdapter(HostAdapter):
|
|
1583
|
+
def _user_marker(self) -> bool:
|
|
1584
|
+
return (Path.home() / self.install_path).is_file()
|
|
1585
|
+
|
|
1586
|
+
def pre_validate(self, root: Path) -> None:
|
|
1587
|
+
from .commands.plugin_antigravity import pre_validate
|
|
1588
|
+
|
|
1589
|
+
pre_validate()
|
|
1590
|
+
|
|
1591
|
+
def ensure_user_agents(
|
|
1592
|
+
self, root: Path, source: Path, *, locale: str | None = None,
|
|
1593
|
+
) -> dict[str, object]:
|
|
1594
|
+
from .commands.plugin_antigravity import install_review_plugin
|
|
1595
|
+
|
|
1596
|
+
return install_review_plugin()
|
|
1597
|
+
|
|
1598
|
+
@property
|
|
1599
|
+
def installed_components(self) -> list[str]:
|
|
1600
|
+
return ["plugin", "agent", "worker", "skill", "workspace-mcp"]
|
|
1601
|
+
|
|
1602
|
+
|
|
1570
1603
|
class ZCodeAdapter(HostAdapter):
|
|
1571
1604
|
"""ZCode IDE adapter."""
|
|
1572
1605
|
|
|
@@ -1692,6 +1725,9 @@ class ChatGptAdapter(HostAdapter):
|
|
|
1692
1725
|
class QoderAdapter(HostAdapter):
|
|
1693
1726
|
"""Qoder AI adapter."""
|
|
1694
1727
|
|
|
1728
|
+
def managed_surfaces(self) -> tuple[str, ...]:
|
|
1729
|
+
return (*super().managed_surfaces(), QODER_PROJECT_MCP_PATHS[0])
|
|
1730
|
+
|
|
1695
1731
|
def _app_markers(self) -> tuple[Path, ...]:
|
|
1696
1732
|
return _qoder_app_markers()
|
|
1697
1733
|
|
|
@@ -1970,6 +2006,7 @@ HOST_ADAPTERS: tuple[HostAdapter, ...] = (
|
|
|
1970
2006
|
*_plugin_backed_adapters(KimiAdapter),
|
|
1971
2007
|
# MiniMax Code 桌面端通过 Plugin V1 注册 Agent、Skill 与 MCP。
|
|
1972
2008
|
*_plugin_backed_adapters(MiniMaxAdapter),
|
|
2009
|
+
*_plugin_backed_adapters(AntigravityAdapter),
|
|
1973
2010
|
WorkBuddyAdapter(
|
|
1974
2011
|
"workbuddy", "WorkBuddy AI", "workbuddy", ".workbuddy",
|
|
1975
2012
|
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",
|
|
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=
|
|
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
|
-
|
|
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 =
|
|
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)
|
|
434
|
+
"`bugx doctor --repair` 在两种情况下会重放安装资源修好引擎:(1) 安装资源版本严格高于全局引擎;(2) 同版本且安装资源自身完好。仅当资源自身也损坏(或需要降级)时才会拒绝,此时请重装 CLI。",
|
|
435
435
|
),
|
|
436
436
|
(
|
|
437
437
|
r"BugX 版本一致性",
|
|
438
438
|
"CLI 命令入口与全局引擎、镜像清单版本声明不一致,存在环境版本漂移。",
|
|
439
|
-
"运行 `bugx doctor --repair`
|
|
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
|
-
"
|
|
470
|
-
"
|
|
469
|
+
"按需构建的本地离线 MCP 运行时沙箱缺失或已损坏。",
|
|
470
|
+
"如需使用需沙箱的扩展 MCP,运行 `bugx mcp-runtime install`(可选按项目启用;这不是全局必需项)。",
|
|
471
471
|
),
|
|
472
472
|
(
|
|
473
473
|
r"MCP 会话进程卫生",
|
|
474
|
-
"
|
|
475
|
-
"运行 bugx
|
|
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
|
-
"
|
|
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
|
-
"
|
|
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
|
-
|
|
412
|
-
|
|
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.
|
|
1115
|
+
if version == "0.1.4":
|
|
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.
|
|
1128
|
+
if version == "0.1.4":
|
|
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
|
-
|
|
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"
|
|
1211
|
-
f"
|
|
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.
|
|
1870
|
+
if value == "0.1.4":
|
|
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.
|
|
1884
|
+
if value == "0.1.4":
|
|
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.
|
|
168
|
+
if version == "0.1.4":
|
|
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():
|