bugx-cli 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -29
- package/core/README.md +5 -3
- package/core/agent/agent_orchestrator.py +3 -0
- package/core/agent/agent_workspace.py +14 -2
- package/core/assets/bugx-wechat-group.png +0 -0
- package/core/assets/twitter_promo_art.jpg +0 -0
- package/core/assets/twitter_promo_card.svg +166 -0
- package/core/assets/twitter_promo_clean.jpg +0 -0
- package/core/assets/twitter_terminal_real.png +0 -0
- package/core/bugx.md +3 -3
- 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-opencode.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 +267 -111
- package/core/host_acp/antigravity.py +153 -0
- package/core/host_acp/kimi.py +175 -0
- package/core/host_acp/minimax.py +28 -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 +25 -4
- 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 +43 -24
- package/core/hosts/kimi.py +293 -0
- package/core/hosts/minimax.py +249 -0
- package/core/hosts/zcode.py +5 -0
- package/core/i18n.py +94 -5
- package/core/infra/README.md +1 -1
- package/core/infra/build_info.py +30 -5
- 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 +16 -23
- 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 +2 -2
- 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/setup_ui_env.py +4 -7
- 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/cli.py +2 -2
- package/core/supervisor/worker_execution.py +16 -3
- package/core/webui/docs_session_service.py +40 -2
- package/core/webui/mcp_inspector.py +12 -6
- package/core/webui/static/index.html +51 -3
- package/core/webui/static/manifest.webmanifest +1 -1
- package/core/webui/static/project-settings.js +18 -3
- package/core/webui/static/robots.txt +36 -0
- package/core/webui/static/sitemap.xml +15 -0
- package/docs/07_distribution/01_README_NPM.md +26 -29
- package/ecosystem/integrations/cline/skills/bugx/SKILL.md +46 -46
- package/ecosystem/integrations/dsh/agents/bugx.md +2 -1
- package/ecosystem/integrations/dsh/dsh-patch.yml +2 -2
- package/ecosystem/integrations/dsh/mcp/package.json +1 -1
- package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +6 -6
- package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +1 -1
- 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 +6 -6
- package/ecosystem/integrations/qoder/CONNECTORS.md +11 -23
- package/ecosystem/integrations/qoder/connector-meta.json +9 -9
- package/ecosystem/integrations/workbuddy/connector-meta.json +9 -9
- package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +8 -7
- package/ecosystem/plugins/bugx/.claude-plugin/marketplace.json +2 -2
- package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +2 -2
- package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +4 -4
- package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +2 -2
- 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 +8 -8
- package/ecosystem/plugins/bugx/skills/bugx-claude/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +3 -3
- package/interfaces/bin/bugx.js +2 -0
- package/interfaces/cli/bugx_cli/__init__.py +2 -2
- package/interfaces/cli/bugx_cli/cli.py +153 -8
- package/interfaces/cli/bugx_cli/commands/agent.py +568 -136
- package/interfaces/cli/bugx_cli/commands/cloud.py +42 -1
- package/interfaces/cli/bugx_cli/commands/doctor.py +668 -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 +99 -62
- package/interfaces/cli/bugx_cli/commands/plugin.py +301 -60
- package/interfaces/cli/bugx_cli/commands/plugin_antigravity.py +350 -0
- package/interfaces/cli/bugx_cli/commands/plugin_claude.py +27 -13
- package/interfaces/cli/bugx_cli/commands/plugin_kimi.py +440 -0
- package/interfaces/cli/bugx_cli/commands/plugin_minimax.py +522 -0
- package/interfaces/cli/bugx_cli/commands/plugin_qoder.py +3 -4
- package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +4 -5
- package/interfaces/cli/bugx_cli/commands/system.py +75 -5
- package/interfaces/cli/bugx_cli/common.py +135 -15
- package/interfaces/cli/bugx_cli/host_adapters.py +190 -7
- package/interfaces/cli/bugx_cli/hosts/registry.py +6 -3
- package/interfaces/cli/bugx_cli/hosts/template_engine.py +31 -11
- 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 +242 -52
- package/package.json +38 -13
- package/pyproject.toml +57 -13
- package/scripts/sync-version.mjs +1 -1
- package/skills/README.md +24 -0
- package/skills/platform/bugx/SKILL.md +50 -0
|
@@ -15,25 +15,26 @@ if TYPE_CHECKING:
|
|
|
15
15
|
|
|
16
16
|
# 宿主入口 frontmatter 触发文案与 Worker 描述
|
|
17
17
|
AGENT_DESCRIPTION_EN = (
|
|
18
|
-
"An autonomous
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
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
|
-
"
|
|
26
|
-
"
|
|
25
|
+
"BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,"
|
|
26
|
+
"减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;"
|
|
27
|
+
"确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。"
|
|
27
28
|
)
|
|
28
29
|
|
|
29
30
|
BUGX_WORKER_DESCRIPTION_ZH = (
|
|
30
|
-
"BugX
|
|
31
|
+
"BugX 并发测试审查 Worker。由 BugX 主智能体并发调度,负责具体代码模块的审查、缺陷排查与自动化测试验证;"
|
|
31
32
|
"仅作为子智能体工作节点协同运行。"
|
|
32
33
|
)
|
|
33
34
|
|
|
34
35
|
BUGX_WORKER_DESCRIPTION_EN = (
|
|
35
|
-
"A concurrent
|
|
36
|
-
"
|
|
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
|
|
@@ -43,6 +44,12 @@ BUGX_WORKER_DESCRIPTION = BUGX_WORKER_DESCRIPTION_ZH
|
|
|
43
44
|
def get_agent_description(locale: str | None = None) -> str:
|
|
44
45
|
"""Return the localized host agent description (fallback to en-US)."""
|
|
45
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
|
|
46
53
|
if loc.startswith("zh"):
|
|
47
54
|
return AGENT_DESCRIPTION_ZH
|
|
48
55
|
return AGENT_DESCRIPTION_EN
|
|
@@ -51,6 +58,12 @@ def get_agent_description(locale: str | None = None) -> str:
|
|
|
51
58
|
def get_worker_description(locale: str | None = None) -> str:
|
|
52
59
|
"""Return the localized concurrent worker description (fallback to en-US)."""
|
|
53
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
|
|
54
67
|
if loc.startswith("zh"):
|
|
55
68
|
return BUGX_WORKER_DESCRIPTION_ZH
|
|
56
69
|
return BUGX_WORKER_DESCRIPTION_EN
|
|
@@ -58,9 +71,16 @@ def get_worker_description(locale: str | None = None) -> str:
|
|
|
58
71
|
|
|
59
72
|
def add_locale_marker(content: str, locale: str | None) -> str:
|
|
60
73
|
"""Record the selected locale without invalidating YAML frontmatter."""
|
|
61
|
-
|
|
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:
|
|
62
82
|
return content
|
|
63
|
-
normalized =
|
|
83
|
+
normalized = loc or "en-US"
|
|
64
84
|
marker = f"<!-- bugx-locale: {normalized} -->\n"
|
|
65
85
|
if content.startswith("---\n"):
|
|
66
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():
|