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.
Files changed (157) hide show
  1. package/README.md +26 -29
  2. package/core/README.md +5 -3
  3. package/core/agent/agent_orchestrator.py +3 -0
  4. package/core/agent/agent_workspace.py +14 -2
  5. package/core/assets/bugx-wechat-group.png +0 -0
  6. package/core/assets/twitter_promo_art.jpg +0 -0
  7. package/core/assets/twitter_promo_card.svg +166 -0
  8. package/core/assets/twitter_promo_clean.jpg +0 -0
  9. package/core/assets/twitter_terminal_real.png +0 -0
  10. package/core/bugx.md +3 -3
  11. package/core/bugx_paths.py +10 -2
  12. package/core/bundled_docs/OVERVIEW.md +310 -0
  13. package/core/bundled_docs/README.md +10 -0
  14. package/core/bundled_docs/README_EN.md +278 -0
  15. package/core/bundled_docs/ai/01_AI_REFERENCE.md +833 -0
  16. package/core/bundled_docs/ai/02_AI_USAGE.md +161 -0
  17. package/core/bundled_docs/ai/03_AI_COMMANDS.md +322 -0
  18. package/core/bundled_docs/guides/01_USER_GUIDE.md +887 -0
  19. package/core/bundled_docs/guides/02_COMMANDS.md +935 -0
  20. package/core/bundled_docs/guides/03_TROUBLESHOOTING.md +763 -0
  21. package/core/bundled_docs/guides/04_CLOUD_AUTH_AND_SYNC_COOKBOOK.md +48 -0
  22. package/core/bundled_docs/guides/05_HOST_MATRIX_AND_DISPATCH.md +23 -0
  23. package/core/bundled_docs/guides/06_PROBES_AND_POC_COOKBOOK.md +49 -0
  24. package/core/bundled_docs/guides/07_LIFECYCLE_AND_RECOVERY_STATES.md +46 -0
  25. package/core/bundled_docs/guides/08_LESSONS_AND_PRIVACY_BOUNDARY.md +35 -0
  26. package/core/bundled_docs/hosts/bugx-claude_SKILL.md +326 -0
  27. package/core/bundled_docs/hosts/bugx-dsh_SKILL.md +229 -0
  28. package/core/bundled_docs/hosts/bugx-opencode_SKILL.md +129 -0
  29. package/core/bundled_docs/hosts/bugx-zcode_SKILL.md +459 -0
  30. package/core/bundled_docs/hosts/bugx_SKILL.md +118 -0
  31. package/core/bundled_docs/hosts/cline_bugx_SKILL.md +69 -0
  32. package/core/bundled_docs/hosts/platform_bugx_SKILL.md +50 -0
  33. package/core/bundled_docs/manifest.json +140 -0
  34. package/core/bundled_docs/reference/01_ENVIRONMENT_VARIABLES.md +421 -0
  35. package/core/bundled_docs/reference/04_REPOSITORY_TOPOLOGY.md +180 -0
  36. package/core/cli-help.txt +7 -3
  37. package/core/cloud_sync/cloud_client.py +81 -2
  38. package/core/cloud_sync/endpoint_router.py +22 -9
  39. package/core/cloud_sync/issue_uploader.py +297 -0
  40. package/core/cloud_sync/sensitive_filter.py +77 -7
  41. package/core/contracts/AGENT_GUIDE.md +3 -9
  42. package/core/contracts/README.md +1 -1
  43. package/core/contracts/bugx-opencode.md +1 -1
  44. package/core/contracts/bugx-runtime-contract.md +10 -20
  45. package/core/contracts/bugx-worker.md +1 -1
  46. package/core/engine-integrity.json +267 -111
  47. package/core/host_acp/antigravity.py +153 -0
  48. package/core/host_acp/kimi.py +175 -0
  49. package/core/host_acp/minimax.py +28 -0
  50. package/core/host_runtime/adapters.py +5 -1
  51. package/core/host_runtime/antigravity.py +162 -0
  52. package/core/host_runtime/host_bootstrap.py +18 -7
  53. package/core/host_runtime/host_evaluators.py +4 -4
  54. package/core/host_runtime/host_registry.py +25 -4
  55. package/core/host_runtime/mcp_process_tracker.py +30 -3
  56. package/core/host_runtime/mcp_registry_gate.py +34 -11
  57. package/core/hosts/antigravity.py +115 -0
  58. package/core/hosts/codex.py +3 -0
  59. package/core/hosts/dsh.py +43 -24
  60. package/core/hosts/kimi.py +293 -0
  61. package/core/hosts/minimax.py +249 -0
  62. package/core/hosts/zcode.py +5 -0
  63. package/core/i18n.py +94 -5
  64. package/core/infra/README.md +1 -1
  65. package/core/infra/build_info.py +30 -5
  66. package/core/launch_phases/README.md +2 -2
  67. package/core/launch_phases/startup_version_gate.py +2 -2
  68. package/core/launch_phases/supervisor_bridge.py +16 -23
  69. package/core/launch_phases/supervisor_degraded.py +7 -5
  70. package/core/ledger/README.md +1 -1
  71. package/core/locales/en-US.json +3 -3
  72. package/core/locales/zh-CN.json +3 -3
  73. package/core/mcp_runtime_support/environment.py +6 -1
  74. package/core/metadata.txt +2 -2
  75. package/core/planning/README.md +1 -1
  76. package/core/planning/prompt_harness.py +2 -2
  77. package/core/probes/codebase_memory_probe.py +43 -24
  78. package/core/probes/probe_registry.py +10 -7
  79. package/core/prompts/command_routing_en.md +6 -5
  80. package/core/prompts/command_routing_zh.md +6 -5
  81. package/core/repair/rsi_rounds.py +3 -0
  82. package/core/repair/self_heal.py +160 -6
  83. package/core/retrieval/README.md +1 -1
  84. package/core/runtime/README.md +1 -1
  85. package/core/runtime/scenario_eval.py +5 -1
  86. package/core/runtime/setup_ui_env.py +4 -7
  87. package/core/runtime/tool_install_targets.py +12 -2
  88. package/core/skills/README.md +4 -2
  89. package/core/skills/bugx_docs_cloud_sync.py +658 -0
  90. package/core/skills/bugx_docs_mcp_server.py +966 -140
  91. package/core/supervisor/README.md +1 -1
  92. package/core/supervisor/cli.py +2 -2
  93. package/core/supervisor/worker_execution.py +16 -3
  94. package/core/webui/docs_session_service.py +40 -2
  95. package/core/webui/mcp_inspector.py +12 -6
  96. package/core/webui/static/index.html +51 -3
  97. package/core/webui/static/manifest.webmanifest +1 -1
  98. package/core/webui/static/project-settings.js +18 -3
  99. package/core/webui/static/robots.txt +36 -0
  100. package/core/webui/static/sitemap.xml +15 -0
  101. package/docs/07_distribution/01_README_NPM.md +26 -29
  102. package/ecosystem/integrations/cline/skills/bugx/SKILL.md +46 -46
  103. package/ecosystem/integrations/dsh/agents/bugx.md +2 -1
  104. package/ecosystem/integrations/dsh/dsh-patch.yml +2 -2
  105. package/ecosystem/integrations/dsh/mcp/package.json +1 -1
  106. package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +6 -6
  107. package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +1 -1
  108. package/ecosystem/integrations/dsh/ui/package.json +1 -1
  109. package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +2 -2
  110. package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
  111. package/ecosystem/integrations/pi/skills/bugx/SKILL.md +6 -6
  112. package/ecosystem/integrations/qoder/CONNECTORS.md +11 -23
  113. package/ecosystem/integrations/qoder/connector-meta.json +9 -9
  114. package/ecosystem/integrations/workbuddy/connector-meta.json +9 -9
  115. package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +8 -7
  116. package/ecosystem/plugins/bugx/.claude-plugin/marketplace.json +2 -2
  117. package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +2 -2
  118. package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +4 -4
  119. package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +2 -2
  120. package/ecosystem/plugins/bugx/agents/bugx-worker.md +14 -18
  121. package/ecosystem/plugins/bugx/agents/bugx.md +45 -49
  122. package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +8 -8
  123. package/ecosystem/plugins/bugx/skills/bugx-claude/SKILL.md +1 -1
  124. package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +1 -1
  125. package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +1 -1
  126. package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +3 -3
  127. package/interfaces/bin/bugx.js +2 -0
  128. package/interfaces/cli/bugx_cli/__init__.py +2 -2
  129. package/interfaces/cli/bugx_cli/cli.py +153 -8
  130. package/interfaces/cli/bugx_cli/commands/agent.py +568 -136
  131. package/interfaces/cli/bugx_cli/commands/cloud.py +42 -1
  132. package/interfaces/cli/bugx_cli/commands/doctor.py +668 -223
  133. package/interfaces/cli/bugx_cli/commands/guide.py +143 -0
  134. package/interfaces/cli/bugx_cli/commands/issue.py +262 -0
  135. package/interfaces/cli/bugx_cli/commands/lifecycle.py +99 -62
  136. package/interfaces/cli/bugx_cli/commands/plugin.py +301 -60
  137. package/interfaces/cli/bugx_cli/commands/plugin_antigravity.py +350 -0
  138. package/interfaces/cli/bugx_cli/commands/plugin_claude.py +27 -13
  139. package/interfaces/cli/bugx_cli/commands/plugin_kimi.py +440 -0
  140. package/interfaces/cli/bugx_cli/commands/plugin_minimax.py +522 -0
  141. package/interfaces/cli/bugx_cli/commands/plugin_qoder.py +3 -4
  142. package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +4 -5
  143. package/interfaces/cli/bugx_cli/commands/system.py +75 -5
  144. package/interfaces/cli/bugx_cli/common.py +135 -15
  145. package/interfaces/cli/bugx_cli/host_adapters.py +190 -7
  146. package/interfaces/cli/bugx_cli/hosts/registry.py +6 -3
  147. package/interfaces/cli/bugx_cli/hosts/template_engine.py +31 -11
  148. package/interfaces/cli/bugx_cli/infra/__init__.py +4 -0
  149. package/interfaces/cli/bugx_cli/infra/ai_advisor.py +14 -12
  150. package/interfaces/cli/bugx_cli/infra/engine_installer.py +76 -10
  151. package/interfaces/cli/bugx_cli/infra/host_sync.py +66 -1
  152. package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +242 -52
  153. package/package.json +38 -13
  154. package/pyproject.toml +57 -13
  155. package/scripts/sync-version.mjs +1 -1
  156. package/skills/README.md +24 -0
  157. package/skills/platform/bugx/SKILL.md +50 -0
@@ -19,17 +19,24 @@
19
19
 
20
20
  from __future__ import annotations
21
21
 
22
+ import importlib
23
+ import importlib.util
22
24
  import json
23
25
  import os
24
26
  import re
25
27
  import shutil
26
28
  import subprocess
29
+ import sys
27
30
  import time
28
31
  from dataclasses import dataclass, field
29
32
  from pathlib import Path
30
33
  from typing import Any, Callable
31
34
 
32
- from core.runtime.tool_install_targets import OPTIONAL_TOOL_PACKAGE_SPECS
35
+ from core.runtime.tool_install_targets import (
36
+ OPTIONAL_TOOL_PACKAGE_SPECS,
37
+ REQUIRED_TOOL_PACKAGE_SPECS,
38
+ TOOL_PACKAGE_SPECS,
39
+ )
33
40
 
34
41
  DEFAULT_MAX_ATTEMPTS = 6
35
42
  DEFAULT_ATTEMPT_TIMEOUT = 120.0
@@ -125,15 +132,20 @@ def resolve_budget() -> Budget:
125
132
  PLAN_REGISTRY: dict[str, tuple[Plan, ...]] = {
126
133
  "codebase-memory": (
127
134
  Plan("pipx 隔离重装固定版本", (
128
- "pipx", "install", "--force", OPTIONAL_TOOL_PACKAGE_SPECS["codebase-memory"],
135
+ "pipx", "install", "--force", REQUIRED_TOOL_PACKAGE_SPECS["codebase-memory"],
129
136
  ),
130
137
  requires="pipx", verify=("codebase-memory-mcp",),
131
- verify_version_spec=OPTIONAL_TOOL_PACKAGE_SPECS["codebase-memory"]),
138
+ verify_version_spec=REQUIRED_TOOL_PACKAGE_SPECS["codebase-memory"]),
132
139
  Plan("uv tool 隔离重装固定版本", (
133
- "uv", "tool", "install", "--reinstall", OPTIONAL_TOOL_PACKAGE_SPECS["codebase-memory"],
140
+ "uv", "tool", "install", "--reinstall", REQUIRED_TOOL_PACKAGE_SPECS["codebase-memory"],
134
141
  ),
135
142
  requires="uv", verify=("codebase-memory-mcp",),
136
- verify_version_spec=OPTIONAL_TOOL_PACKAGE_SPECS["codebase-memory"]),
143
+ verify_version_spec=REQUIRED_TOOL_PACKAGE_SPECS["codebase-memory"]),
144
+ Plan("BugX 隔离 venv 安装固定版本", (
145
+ "__bugx_venv_pip__", "codebase-memory", REQUIRED_TOOL_PACKAGE_SPECS["codebase-memory"],
146
+ ),
147
+ requires=None, verify=("codebase-memory-mcp",),
148
+ verify_version_spec=REQUIRED_TOOL_PACKAGE_SPECS["codebase-memory"]),
137
149
  ),
138
150
  "ast-grep": (
139
151
  Plan("pipx 隔离重装固定版本", (
@@ -217,7 +229,65 @@ Which = Callable[[str], str | None]
217
229
  Clock = Callable[[], float]
218
230
 
219
231
 
232
+ def _bugx_home_root() -> Path:
233
+ configured = os.environ.get("BUGX_HOME", "").strip()
234
+ if configured:
235
+ return Path(configured).expanduser().resolve()
236
+ return (Path.home() / ".bugx").resolve()
237
+
238
+
239
+ def bugx_pydeps_dir() -> Path:
240
+ return _bugx_home_root() / "tools" / "pydeps"
241
+
242
+
243
+ def mount_bugx_pydeps() -> Path | None:
244
+ target = bugx_pydeps_dir()
245
+ if target.is_symlink() or not target.is_dir():
246
+ return None
247
+ text = str(target)
248
+ if text not in sys.path:
249
+ sys.path.insert(0, text)
250
+ return target
251
+
252
+
253
+ def _run_isolated_venv_pip(tool_dir_name: str, package_spec: str, timeout: float) -> tuple[int | None, str]:
254
+ venv_dir = _bugx_home_root() / "tools" / tool_dir_name
255
+ scripts = "Scripts" if os.name == "nt" else "bin"
256
+ py_name = "python.exe" if os.name == "nt" else "python"
257
+ venv_py = venv_dir / scripts / py_name
258
+ outputs: list[str] = []
259
+ if not venv_py.is_file():
260
+ if venv_dir.exists() and not venv_dir.is_symlink():
261
+ shutil.rmtree(venv_dir, ignore_errors=True)
262
+ venv_dir.parent.mkdir(parents=True, exist_ok=True)
263
+ try:
264
+ proc = subprocess.run(
265
+ [sys.executable, "-m", "venv", str(venv_dir)],
266
+ capture_output=True, text=True, timeout=min(timeout, 120.0), check=False,
267
+ )
268
+ outputs.append(f"{proc.stdout or ''}\n{proc.stderr or ''}")
269
+ if proc.returncode != 0 or not venv_py.is_file():
270
+ return proc.returncode or 1, "\n".join(outputs)
271
+ except subprocess.TimeoutExpired:
272
+ return None, f"timeout creating venv after {timeout}s"
273
+ except OSError as exc:
274
+ return None, f"{exc.__class__.__name__}: {exc}"
275
+ try:
276
+ proc = subprocess.run(
277
+ [str(venv_py), "-m", "pip", "install", "--no-input", "--upgrade", package_spec],
278
+ capture_output=True, text=True, timeout=timeout, check=False,
279
+ )
280
+ outputs.append(f"{proc.stdout or ''}\n{proc.stderr or ''}")
281
+ return proc.returncode, "\n".join(outputs)
282
+ except subprocess.TimeoutExpired:
283
+ return None, f"timeout after {timeout}s"
284
+ except OSError as exc:
285
+ return None, f"{exc.__class__.__name__}: {exc}"
286
+
287
+
220
288
  def _default_runner(argv: tuple[str, ...], timeout: float) -> tuple[int | None, str]:
289
+ if len(argv) >= 3 and argv[0] == "__bugx_venv_pip__":
290
+ return _run_isolated_venv_pip(argv[1], argv[2], timeout)
221
291
  try:
222
292
  proc = subprocess.run(list(argv), capture_output=True, text=True,
223
293
  timeout=timeout, check=False)
@@ -383,21 +453,29 @@ def _verified(
383
453
  )
384
454
  if not match:
385
455
  return False
386
- if plan.verify_version_spec not in OPTIONAL_TOOL_PACKAGE_SPECS.values():
456
+ if plan.verify_version_spec not in TOOL_PACKAGE_SPECS.values():
387
457
  return False
388
458
  package = match.group("package")
389
459
  expected = match.group("version")
390
460
  if package == "codebase-memory-mcp":
461
+ used_default = False
391
462
  if version_resolver is None:
392
463
  try:
393
464
  from core.probes import codebase_memory_probe
394
465
  version_resolver = codebase_memory_probe.resolve_compatible_binary
466
+ used_default = True
395
467
  except ImportError:
396
468
  return False
397
469
  try:
470
+ if used_default:
471
+ return bool(version_resolver(expected_version=expected, timeout_seconds=120.0))
398
472
  return bool(version_resolver(expected_version=expected))
399
473
  except Exception:
400
474
  return False
475
+ if package == "tree-sitter-language-pack":
476
+ mount_bugx_pydeps()
477
+ importlib.invalidate_caches()
478
+ return importlib.util.find_spec("tree_sitter_language_pack") is not None
401
479
  try:
402
480
  if package in {"semgrep", "bandit"}:
403
481
  from core.probes import sast_probe
@@ -602,3 +680,79 @@ def escalation_lines(report: HealReport) -> list[str]:
602
680
  if not lines:
603
681
  lines.append(" · 无可用方案(该工具未登记方案阶梯)")
604
682
  return lines
683
+
684
+
685
+ def ensure_codebase_memory_ready(root: Path | None = None) -> tuple[bool, str]:
686
+ """校验并在缺失/错版时直接安装 codebase-memory-mcp 固定版本,禁止降级。"""
687
+ try:
688
+ from core.probes import codebase_memory_probe
689
+ expected = codebase_memory_probe._pinned_cli_version()
690
+ executable = codebase_memory_probe.resolve_compatible_binary(
691
+ expected_version=expected, timeout_seconds=30.0,
692
+ )
693
+ if executable:
694
+ return True, f"已就绪 ({executable} == {expected})"
695
+ except Exception:
696
+ pass
697
+
698
+ ok, heal_report = heal_tool(
699
+ "codebase-memory",
700
+ detail=f"缺失必装核心图谱组件 {REQUIRED_TOOL_PACKAGE_SPECS['codebase-memory']}",
701
+ root=root,
702
+ )
703
+ if ok:
704
+ detail = "; ".join(heal_report.healed) or f"已安装 {REQUIRED_TOOL_PACKAGE_SPECS['codebase-memory']}"
705
+ return True, detail
706
+ details = [line.strip() for line in escalation_lines(heal_report)]
707
+ return False, ";".join(details) if details else f"安装失败:{REQUIRED_TOOL_PACKAGE_SPECS['codebase-memory']}"
708
+
709
+
710
+ def ensure_tree_sitter_ready(timeout: float = 120.0) -> tuple[bool, str]:
711
+ """校验并在缺失时安装 tree-sitter-language-pack(含 PEP 668 隔离目录兜底)。"""
712
+ mount_bugx_pydeps()
713
+ importlib.invalidate_caches()
714
+ if importlib.util.find_spec("tree_sitter_language_pack") is not None:
715
+ return True, "已就绪"
716
+
717
+ spec = REQUIRED_TOOL_PACKAGE_SPECS["tree-sitter"]
718
+ errors: list[str] = []
719
+
720
+ try:
721
+ proc = subprocess.run(
722
+ [sys.executable, "-m", "pip", "install", "--no-input", spec, "--no-warn-script-location"],
723
+ capture_output=True, text=True, timeout=timeout, check=False,
724
+ )
725
+ importlib.invalidate_caches()
726
+ if proc.returncode == 0 and importlib.util.find_spec("tree_sitter_language_pack") is not None:
727
+ return True, f"已安装 {spec}"
728
+ tail = ((proc.stderr or "") + "\n" + (proc.stdout or "")).strip()[-300:]
729
+ if tail:
730
+ errors.append(f"pip: {tail}")
731
+ except (OSError, subprocess.TimeoutExpired) as exc:
732
+ errors.append(f"pip: {exc}")
733
+
734
+ target_dir = bugx_pydeps_dir()
735
+ if target_dir.is_symlink():
736
+ return False, f"隔离依赖路径不能是符号链接: {target_dir}"
737
+ try:
738
+ target_dir.mkdir(parents=True, exist_ok=True)
739
+ for cmd in (
740
+ [sys.executable, "-m", "pip", "install", "--no-input", "--upgrade", "--target", str(target_dir), spec],
741
+ *(
742
+ [[uv_bin, "pip", "install", "--python", sys.executable, "--target", str(target_dir), spec]]
743
+ if (uv_bin := shutil.which("uv")) else []
744
+ ),
745
+ ):
746
+ proc = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout, check=False)
747
+ mount_bugx_pydeps()
748
+ importlib.invalidate_caches()
749
+ if proc.returncode == 0 and importlib.util.find_spec("tree_sitter_language_pack") is not None:
750
+ return True, f"已安装到隔离目录 {target_dir}"
751
+ tail = ((proc.stderr or "") + "\n" + (proc.stdout or "")).strip()[-300:]
752
+ if tail:
753
+ errors.append(tail)
754
+ except (OSError, subprocess.TimeoutExpired) as exc:
755
+ errors.append(str(exc))
756
+
757
+ return False, ";".join(errors[-2:]) if errors else f"无法安装 {spec}"
758
+
@@ -1,6 +1,6 @@
1
1
  # BugX Retrieval Engine (代码切片、拓扑与混合检索增强引擎)
2
2
 
3
- > **版本契约**: `0.1.2` | **所属分层**: `Layer 2: 分析、切片与探测引擎`
3
+ > **版本契约**: `0.1.4` | **所属分层**: `Layer 2: 分析、切片与探测引擎`
4
4
  > **工程规范**: 参见 [`docs/02_architecture/05_ARCH_NOMENCLATURE_GUIDE.md`](../../docs/02_architecture/05_ARCH_NOMENCLATURE_GUIDE.md)
5
5
  > **守卫机制**: `scripts/verify_directory_indices.py` (100% 物理条目索引覆盖)
6
6
 
@@ -1,6 +1,6 @@
1
1
  # BugX Core Runtime Subsystem (核心运行时、环境与基础设施)
2
2
 
3
- > **版本契约**: `0.1.2` | **所属分层**: `Layer 0: 基础设施与操作系统抽象`
3
+ > **版本契约**: `0.1.4` | **所属分层**: `Layer 0: 基础设施与操作系统抽象`
4
4
  > **工程规范**: 参见 [`docs/02_architecture/05_ARCH_NOMENCLATURE_GUIDE.md`](../../docs/02_architecture/05_ARCH_NOMENCLATURE_GUIDE.md)
5
5
  > **守卫机制**: `scripts/verify_directory_indices.py` (100% 物理条目索引覆盖)
6
6
 
@@ -141,11 +141,15 @@ def _run(argv: list[str], *, cwd: Path, timeout: float = 120.0,
141
141
  # L3 等场景验证当前 checkout;不让已安装的旧引擎成为量具。
142
142
  merged["BUGX_DEV_MODE"] = "1"
143
143
  # 源码树里的版本声明是构建模板;开发态启动门禁需要同一解析值。
144
- merged["BUGX_VERSION"] = os.environ.get("BUGX_VERSION", "0.1.2")
144
+ merged["BUGX_VERSION"] = os.environ.get("BUGX_VERSION", "0.1.4")
145
145
  merged["HOME"] = str(_sandbox_home())
146
146
  try:
147
147
  proc = subprocess.run(
148
148
  argv, cwd=str(cwd), capture_output=True, text=True,
149
+ # 场景评测是无人值守量具;如果外层宿主恰好有 TTY,子命令不能
150
+ # 继承它再偷偷阻塞在 input()。显式关闭 stdin,让意外交互立即
151
+ # 得到 EOF/失败,而不是把 RSI 轮次挂成数分钟的假运行。
152
+ stdin=subprocess.DEVNULL,
149
153
  timeout=timeout, env=merged, check=False,
150
154
  )
151
155
  return proc.returncode, proc.stdout, proc.stderr
@@ -34,8 +34,7 @@ PLAYWRIGHT_MCP_VERSION = "0.0.79"
34
34
  PLAYWRIGHT_BROWSER_VERSION = "1.63.0-alpha-2026-08-05"
35
35
  AGENT_TTY_VERSION = "0.5.0"
36
36
  PEXPECT_VERSION = "4.9.0"
37
- NODE_MIN_MAJOR = 24
38
- NODE_MAX_MAJOR = 27
37
+ NODE_MIN_MAJOR = 20
39
38
 
40
39
 
41
40
  def sh(cmd: list[str], **kw) -> subprocess.CompletedProcess:
@@ -54,10 +53,9 @@ def node_ok() -> tuple[bool, str]:
54
53
  major = int(version.lstrip("v").split(".", 1)[0])
55
54
  except ValueError:
56
55
  return False, f"node 版本无法解析: {version}"
57
- if not NODE_MIN_MAJOR <= major < NODE_MAX_MAJOR:
56
+ if major < NODE_MIN_MAJOR:
58
57
  return False, (
59
- f"node {version} 不兼容(固定工具链要求 "
60
- f">={NODE_MIN_MAJOR}, <{NODE_MAX_MAJOR})"
58
+ f"node {version} 不兼容(固定工具链要求 >={NODE_MIN_MAJOR})"
61
59
  )
62
60
  return True, f"node {version}"
63
61
 
@@ -141,8 +139,7 @@ def install() -> int:
141
139
  print("=" * 52)
142
140
  if not node_ok()[0]:
143
141
  print(
144
- f"✗ Node.js 版本不兼容,请安装 >= {NODE_MIN_MAJOR} 且 "
145
- f"< {NODE_MAX_MAJOR}(https://nodejs.org)"
142
+ f"✗ Node.js 版本不兼容,请安装 >= {NODE_MIN_MAJOR}(https://nodejs.org)"
146
143
  )
147
144
  return 1
148
145
  npx = shutil.which("npx")
@@ -1,16 +1,26 @@
1
- """Pinned top-level package specs used by optional-tool probes and self-heal."""
1
+ """Pinned top-level package specs used by required and optional tool probes."""
2
2
 
3
- OPTIONAL_TOOL_PACKAGE_SPECS = {
3
+ REQUIRED_TOOL_PACKAGE_SPECS = {
4
4
  "codebase-memory": "codebase-memory-mcp==0.12.1",
5
+ "tree-sitter": "tree-sitter-language-pack==1.14.3",
6
+ }
7
+
8
+ OPTIONAL_TOOL_PACKAGE_SPECS = {
5
9
  "ast-grep": "ast-grep-cli==0.45.1",
6
10
  "semgrep": "semgrep==1.182.0",
7
11
  "bandit": "bandit==1.9.4",
8
12
  }
9
13
 
14
+ TOOL_PACKAGE_SPECS = {
15
+ **REQUIRED_TOOL_PACKAGE_SPECS,
16
+ **OPTIONAL_TOOL_PACKAGE_SPECS,
17
+ }
18
+
10
19
  # Only these probe capabilities may trigger self-healing. Values are trusted
11
20
  # registry keys, never package names copied from probe output.
12
21
  PROBE_REPAIR_TARGETS = {
13
22
  "codebase-memory": ("codebase-memory",),
23
+ "tree-sitter": ("tree-sitter",),
14
24
  "efficiency": ("ast-grep",),
15
25
  "sast": ("bandit", "semgrep"),
16
26
  "bandit": ("bandit",),
@@ -16,7 +16,8 @@ flowchart TD
16
16
 
17
17
  subgraph MCPServer["2. MCP 协议服务 (Model Context Protocol Services)"]
18
18
  BMS["bugx_mcp_server.py<br/>BugX 官方标准 MCP Server 入口与状态机暴露"]
19
- BDMS["bugx_docs_mcp_server.py<br/>本地项目文档与架构知识库检索服务"]
19
+ BDMS["bugx_docs_mcp_server.py<br/>双作用域章节级文档与架构知识库检索服务"]
20
+ BDCS["bugx_docs_cloud_sync.py<br/>官方文档不可变内容寻址缓存与热同步引擎"]
20
21
  MSP["mcp_session_proof.py<br/>MCP 会话自证明与受控退休协议"]
21
22
  MR["mcp_runtime.py<br/>离线锁定版本 MCP 包安装与生命周期管理"]
22
23
  end
@@ -36,7 +37,8 @@ flowchart TD
36
37
  | 文件名 | 职责与功能定位 | 关键类 / 函数 |
37
38
  | :--- | :--- | :--- |
38
39
  | `__init__.py` | 技能与 MCP 子系统聚合导出与包入口 | `__all__` |
39
- | `bugx_docs_mcp_server.py` | 文档 MCP 服务端,基于 SQLite FTS5 提供本地代码库架构与知识检索 | `DocsMcpError`, `index_documents`, `call_tool`, `serve` |
40
+ | `bugx_docs_cloud_sync.py` | 官方文档云端热同步客户端,管理不可变 SHA-256 缓存、单飞锁与安全 GC | `sync_official_docs`, `current_cached_db`, `remote_search_docs` |
41
+ | `bugx_docs_mcp_server.py` | 双作用域文档 MCP 服务端,基于 FTS5 trigram 与章节索引提供检索与目录浏览 | `DocsMcpError`, `index_documents`, `call_tool`, `serve` |
40
42
  | `bugx_mcp_server.py` | BugX 核心 Supervisor MCP 服务端,向外部 Agent 暴露审计状态机 | `BugxMcpService`, `SERVER_NAME`, `SERVER_VERSION` |
41
43
  | `mcp_runtime.py` | 离线 MCP 运行时,负责包隔离安装、版本回滚与沙箱启动 | `install_runtime`, `rollback_runtime`, `start_server`, `doctor_runtime` |
42
44
  | `mcp_session_proof.py` | MCP 会话自证明与安全退役握手协议,防止 PID 复用与状态竞争 | `write_proof`, `read_proof`, `validate_proof`, `retire_target` |