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
@@ -0,0 +1,249 @@
1
+ #!/usr/bin/env python3
2
+ """core/hosts/minimax.py - MiniMax Code desktop Plugin V1 host.
3
+
4
+ Facts captured from the installed MiniMax Code 3.1.17 package on Windows and its
5
+ embedded local-plugin-v1 contract:
6
+
7
+ * user plugins are discovered below ~/.minimax/plugins/<plugin>/;
8
+ * the package manifest is .minimax-plugin/plugin.json;
9
+ * MCP servers are declared in servers.mcp.json;
10
+ * plugin subagents are Markdown files under agents/ and Skills under skills/;
11
+ * the Agents roster uses ~/.minimax/agents/<name>/agent.md for Custom Agents.
12
+
13
+ The desktop package exposes the PluginSystem/MCP/Agent surface, but this
14
+ repository has not verified a MiniMax Code headless or standard ACP entry point.
15
+ Those channels therefore fail closed instead of borrowing Kimi or another host's
16
+ flags.
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ import os
22
+ import platform
23
+ import shutil
24
+ from pathlib import Path
25
+
26
+ from .base import (
27
+ AcpFacet,
28
+ EngineRunFacet,
29
+ HostPlugin,
30
+ HostPluginError,
31
+ IdentityFacet,
32
+ InstallFacet,
33
+ McpWriteFacet,
34
+ RunContext,
35
+ STATUS_READY,
36
+ WorkerRuntimeFacet,
37
+ )
38
+
39
+ __all__ = ["PLUGIN", "is_available", "run_static_degraded"]
40
+
41
+ _NAME = "minimax"
42
+ _DATA_ENV = "MINIMAX_DATA_DIR"
43
+ _DEFAULT_DATA_DIR_NAME = ".minimax"
44
+ _PLUGIN_RELATIVE_ROOT = ("plugins", "bugx")
45
+
46
+
47
+ def _minimax_data_dir() -> Path:
48
+ configured = os.environ.get(_DATA_ENV)
49
+ if configured is not None:
50
+ if not configured.strip():
51
+ raise HostPluginError(f"{_DATA_ENV} 不能为空")
52
+ return Path(configured).expanduser()
53
+ return Path.home() / _DEFAULT_DATA_DIR_NAME
54
+
55
+
56
+ def _minimax_plugin_root() -> Path:
57
+ return _minimax_data_dir().joinpath(*_PLUGIN_RELATIVE_ROOT)
58
+
59
+
60
+ def _windows_drive_roots() -> tuple[Path, ...]:
61
+ if platform.system() != "Windows":
62
+ return ()
63
+ try:
64
+ import ctypes
65
+
66
+ mask = int(ctypes.windll.kernel32.GetLogicalDrives())
67
+ except (AttributeError, OSError, TypeError, ValueError):
68
+ return ()
69
+ return tuple(
70
+ Path(f"{chr(ord('A') + index)}:/")
71
+ for index in range(26)
72
+ if mask & (1 << index)
73
+ )
74
+
75
+
76
+ def _minimax_app_markers() -> tuple[Path, ...]:
77
+ """Return bounded MiniMax Code installation candidates; never scan a drive."""
78
+ home = Path.home()
79
+ markers: list[Path] = []
80
+ if platform.system() == "Darwin":
81
+ markers.extend((
82
+ Path("/Applications/MiniMax Code.app"),
83
+ home / "Applications" / "MiniMax Code.app",
84
+ ))
85
+ elif os.name != "nt":
86
+ markers.extend((
87
+ home / ".local" / "share" / "applications" / "minimax-code.desktop",
88
+ Path("/opt/minimax/MiniMax Code/MiniMax Code"),
89
+ ))
90
+
91
+ bases: list[Path] = []
92
+ for variable in (
93
+ "LOCALAPPDATA", "APPDATA", "PROGRAMFILES", "PROGRAMFILES(X86)",
94
+ ):
95
+ value = os.environ.get(variable)
96
+ if value:
97
+ bases.append(Path(value))
98
+ bases.extend(_windows_drive_roots())
99
+
100
+ for base in bases:
101
+ markers.extend((
102
+ base / "minimax" / "MiniMax Code" / "MiniMax Code.exe",
103
+ base / "MiniMax" / "MiniMax Code" / "MiniMax Code.exe",
104
+ base / "Programs" / "minimax" / "MiniMax Code" / "MiniMax Code.exe",
105
+ base / "Programs" / "MiniMax" / "MiniMax Code" / "MiniMax Code.exe",
106
+ base / "Program Files" / "minimax" / "MiniMax Code" / "MiniMax Code.exe",
107
+ base / "Program Files (x86)" / "minimax" / "MiniMax Code" / "MiniMax Code.exe",
108
+ ))
109
+ return tuple(dict.fromkeys(markers))
110
+
111
+
112
+ def _unsupported_headless(_ctx: RunContext) -> list[str]:
113
+ raise HostPluginError(
114
+ "MiniMax Code 当前仅完成桌面 Plugin V1 适配;headless CLI 入口和 flag 尚未取证,拒绝伪造启动参数"
115
+ )
116
+
117
+
118
+ def _unsupported_autonomous(_ctx: RunContext) -> list[str]:
119
+ raise HostPluginError(
120
+ "MiniMax Code 当前仅完成桌面 Agent/MCP 插件适配;自治 CLI 入口尚未取证,拒绝伪造启动参数"
121
+ )
122
+
123
+
124
+ def _mcp_config_paths(_root: Path) -> tuple[Path, ...]:
125
+ return (_minimax_plugin_root() / "servers.mcp.json",)
126
+
127
+
128
+ def _agent_config_path(_root: Path) -> Path:
129
+ return _minimax_data_dir() / "agents" / "bugx" / "agent.md"
130
+
131
+
132
+ def _resolve_minimax_cli() -> str | None:
133
+ """Only report a PATH-resolved CLI; do not infer its command-line contract."""
134
+ return shutil.which("mcode")
135
+
136
+
137
+ PLUGIN = HostPlugin(
138
+ identity=IdentityFacet(
139
+ name=_NAME,
140
+ label="MiniMax Code",
141
+ order=16,
142
+ executable="mcode",
143
+ markers=(".minimax/plugins/bugx/.minimax-plugin/plugin.json", ".minimax"),
144
+ aliases=("minimax-code", "minimaxcode", "mcode"),
145
+ app_markers=_minimax_app_markers,
146
+ native_question=False,
147
+ ),
148
+ status=STATUS_READY,
149
+ install=InstallFacet(
150
+ kind="plugin",
151
+ path=".minimax/plugins/bugx",
152
+ entry_mode="user-registration",
153
+ marker=".minimax",
154
+ required_paths=(),
155
+ capabilities=frozenset({
156
+ "user-agent-registration",
157
+ "user-level-plugin",
158
+ }),
159
+ interaction={
160
+ "tool": "MiniMax Code Agent UI",
161
+ "single_select": "host-native",
162
+ "multi_select": "host-native",
163
+ },
164
+ tools_line="read, write, edit, bash, grep, glob, web_fetch",
165
+ mcp_relpaths=(),
166
+ worker_subagent=True,
167
+ worker_entry_path=".minimax/plugins/bugx/agents/bugx-worker.md",
168
+ generated_dirs=(),
169
+ sweepable=False,
170
+ ),
171
+ engine_run=EngineRunFacet(
172
+ supports_headless=False,
173
+ headless_argv=_unsupported_headless,
174
+ autonomous_argv=_unsupported_autonomous,
175
+ mcp_config_paths=_mcp_config_paths,
176
+ agent_config_path=_agent_config_path,
177
+ mcp_health=None,
178
+ host_surface="desktop",
179
+ native_task=False,
180
+ ),
181
+ worker_runtime=WorkerRuntimeFacet(
182
+ mode="serial",
183
+ max_concurrency=1,
184
+ requires_process_mode=False,
185
+ sandbox_sync=(),
186
+ provider_key=_NAME,
187
+ autonomous_cli=False,
188
+ ),
189
+ mcp_write=McpWriteFacet(
190
+ container_key="mcpServers",
191
+ writer_key=_NAME,
192
+ project_relpath=None,
193
+ global_scope="~/.minimax/plugins/bugx/servers.mcp.json",
194
+ mirror_relpaths=(),
195
+ requires_absolutize=False,
196
+ entry_extra={},
197
+ custom_writer=True,
198
+ ),
199
+ acp=AcpFacet(plugin=_NAME),
200
+ )
201
+
202
+
203
+ def is_available() -> tuple[bool, str]:
204
+ """Report the local CLI without claiming its unverified flags are supported."""
205
+ path = _resolve_minimax_cli()
206
+ if path:
207
+ return True, path
208
+ app_path = next((path for path in _minimax_app_markers() if path.is_file()), None)
209
+ if app_path:
210
+ return True, str(app_path)
211
+ return False, "MiniMax Code desktop/CLI 未在已知位置找到"
212
+
213
+
214
+ def run_static_degraded(root: Path | None = None) -> dict:
215
+ """Return static plugin facts; never report a live desktop session as healthy."""
216
+ available, availability_detail = is_available()
217
+ plugin_root = _minimax_plugin_root()
218
+ manifest = plugin_root / ".minimax-plugin" / "plugin.json"
219
+ return {
220
+ "plugin": _NAME,
221
+ "schema_version": 1,
222
+ "success": available,
223
+ "status": "degraded",
224
+ "degraded": True,
225
+ "degraded_reason": "static_facts_only" if available else "minimax_host_not_found",
226
+ "probe_mode": "static_degraded",
227
+ "headless_available": False,
228
+ "native_task_available": False,
229
+ "identity": {
230
+ "executable": PLUGIN.identity.executable,
231
+ "aliases": list(PLUGIN.identity.aliases),
232
+ "markers": list(PLUGIN.identity.markers),
233
+ },
234
+ "agent_entry": str(_agent_config_path(root or Path.cwd())),
235
+ "worker_entry": str(plugin_root / "agents" / "bugx-worker.md"),
236
+ "plugin_manifest": str(manifest),
237
+ "mcp_config": str(plugin_root / "servers.mcp.json"),
238
+ "findings": [],
239
+ "evidence": {
240
+ "availability_detail": availability_detail,
241
+ "project_root": str(root) if root else None,
242
+ "plugin_installed": manifest.is_file(),
243
+ },
244
+ "metadata": {
245
+ "degraded_mode": "static_plugin_facts_only",
246
+ "acp": "unavailable(尚未取证到 MiniMax Code 标准 ACP 入口)",
247
+ "fallback": "MiniMax Code 以桌面 Plugin V1 运行;BugX 不代装宿主、不伪造 headless/ACP",
248
+ },
249
+ }
@@ -106,6 +106,11 @@ def _zcode_app_markers() -> tuple[Path, ...]:
106
106
  base / "Z.ai" / "ZCode" / "ZCode.exe",
107
107
  base / "Programs" / "ZCode" / "ZCode.exe",
108
108
  base / "Programs" / "Z.ai" / "ZCode.exe",
109
+ base / "Programs" / "Z.ai" / "ZCode" / "ZCode.exe",
110
+ base / "Program Files" / "ZCode" / "ZCode.exe",
111
+ base / "Program Files (x86)" / "ZCode" / "ZCode.exe",
112
+ base / "Program Files" / "Z.ai" / "ZCode" / "ZCode.exe",
113
+ base / "Program Files (x86)" / "Z.ai" / "ZCode" / "ZCode.exe",
109
114
  ))
110
115
  return tuple(markers)
111
116
 
package/core/i18n.py CHANGED
@@ -11,6 +11,8 @@ from __future__ import annotations
11
11
  from dataclasses import dataclass
12
12
  import json
13
13
  import os
14
+ import re
15
+ import sys
14
16
  from functools import lru_cache
15
17
  from pathlib import Path
16
18
  from typing import Any, Mapping
@@ -38,12 +40,22 @@ class LocaleResolution:
38
40
  }
39
41
 
40
42
 
43
+ def _is_neutral_locale(raw: str) -> bool:
44
+ """Check if raw locale string represents a neutral POSIX placeholder (e.g. C, POSIX, C.UTF-8)."""
45
+ if not isinstance(raw, str):
46
+ return False
47
+ stripped = raw.strip()
48
+ if not stripped:
49
+ return False
50
+ token = stripped.split(".", 1)[0].split("@", 1)[0].replace("_", "-").casefold()
51
+ return token in {"c", "posix"}
52
+
53
+
41
54
  def normalize_locale(value: object) -> str | None:
42
55
  """Normalize a BCP-47/POSIX-ish locale to a supported locale.
43
56
 
44
- ``None`` means the input is not supported. ``C``/``POSIX`` are treated as
45
- the conventional English process locale, while arbitrary languages are not
46
- silently mistaken for Chinese.
57
+ ``None`` means the input is not supported or is neutral (e.g. C/POSIX).
58
+ Explicit English and Chinese locales map to ``en-US`` and ``zh-CN`` respectively.
47
59
  """
48
60
  if not isinstance(value, str):
49
61
  return None
@@ -56,7 +68,7 @@ def normalize_locale(value: object) -> str | None:
56
68
  if not parts:
57
69
  return None
58
70
  primary = parts[0].casefold()
59
- if primary in {"c", "posix", "en", "eng"}:
71
+ if primary in {"en", "eng"}:
60
72
  return "en-US"
61
73
  if primary in {"zh", "chi", "zho"}:
62
74
  # The first release intentionally has one Chinese regional catalog.
@@ -82,6 +94,71 @@ def _read_preference(path: Path) -> str | None:
82
94
  return None
83
95
 
84
96
 
97
+ def _detect_system_locale() -> LocaleResolution | None:
98
+ """Detect display locale from OS native system preferences (macOS, system, timezone)."""
99
+ # 1. macOS (darwin)
100
+ if sys.platform == "darwin":
101
+ # Fast path: read ~/Library/Preferences/.GlobalPreferences.plist (~2ms via plistlib)
102
+ try:
103
+ plist_path = Path.home() / "Library" / "Preferences" / ".GlobalPreferences.plist"
104
+ if plist_path.is_file() and not plist_path.is_symlink():
105
+ import plistlib
106
+ with plist_path.open("rb") as f:
107
+ prefs = plistlib.load(f)
108
+ languages = prefs.get("AppleLanguages")
109
+ if isinstance(languages, (list, tuple)) and languages:
110
+ for lang in languages:
111
+ if isinstance(lang, str):
112
+ resolved = normalize_locale(lang)
113
+ if resolved:
114
+ return LocaleResolution(lang, resolved, "system-preference")
115
+ apple_locale = prefs.get("AppleLocale")
116
+ if isinstance(apple_locale, str) and apple_locale:
117
+ resolved = normalize_locale(apple_locale)
118
+ if resolved:
119
+ return LocaleResolution(apple_locale, resolved, "system-preference")
120
+ except Exception:
121
+ pass
122
+
123
+ # Subprocess fallback for macOS if plist direct read failed
124
+ try:
125
+ import subprocess
126
+ out = subprocess.check_output(
127
+ ["defaults", "read", "-g", "AppleLanguages"],
128
+ text=True, stderr=subprocess.DEVNULL, timeout=1,
129
+ )
130
+ for m in re.finditer(r'"([^"]+)"', out):
131
+ lang = m.group(1).strip()
132
+ resolved = normalize_locale(lang)
133
+ if resolved:
134
+ return LocaleResolution(lang, resolved, "system-preference")
135
+ except Exception:
136
+ pass
137
+
138
+ # 2. Python locale.getlocale() (for non-darwin or fallback)
139
+ try:
140
+ import locale as py_locale
141
+ loc = py_locale.getlocale()[0]
142
+ if loc and not _is_neutral_locale(loc):
143
+ resolved = normalize_locale(loc)
144
+ if resolved:
145
+ return LocaleResolution(loc, resolved, "system-locale")
146
+ except Exception:
147
+ pass
148
+
149
+ # 3. Timezone heuristic (East Asia / China UTC+8)
150
+ try:
151
+ import time
152
+ offset_hours = -time.timezone // 3600
153
+ tz_names = tuple(name.upper() for name in time.tzname)
154
+ if offset_hours == 8 and any(name in {"CST", "CHINA", "BEIJING", "SHANGHAI", "HKT", "CST-8"} for name in tz_names):
155
+ return LocaleResolution("zh-CN", "zh-CN", "timezone-hint")
156
+ except Exception:
157
+ pass
158
+
159
+ return None
160
+
161
+
85
162
  def resolve_locale(
86
163
  *,
87
164
  environ: Mapping[str, str] | None = None,
@@ -122,10 +199,14 @@ def resolve_locale(
122
199
  f"unsupported locale: {requested}",
123
200
  )
124
201
 
202
+ saw_neutral = False
125
203
  for key in _ENV_KEYS:
126
204
  raw = env.get(key, "").strip()
127
205
  if not raw:
128
206
  continue
207
+ if _is_neutral_locale(raw):
208
+ saw_neutral = True
209
+ continue
129
210
  resolved = normalize_locale(raw)
130
211
  if resolved:
131
212
  return LocaleResolution(raw, resolved, key)
@@ -133,7 +214,15 @@ def resolve_locale(
133
214
  raw, DEFAULT_LOCALE, key,
134
215
  f"unsupported locale: {raw}",
135
216
  )
136
- return LocaleResolution(None, DEFAULT_LOCALE, "default")
217
+
218
+ # 4. OS native preference detection (macOS AppleLanguages, system locale, timezone)
219
+ if environ is None:
220
+ detected = _detect_system_locale()
221
+ if detected is not None:
222
+ return detected
223
+
224
+ fallback_reason = "neutral locale: C/POSIX" if saw_neutral else None
225
+ return LocaleResolution(None, DEFAULT_LOCALE, "default", fallback_reason)
137
226
 
138
227
 
139
228
  def _catalog_path(locale: str) -> Path:
@@ -1,6 +1,6 @@
1
1
  # BugX Core Infrastructure & Primitives (核心基础设施与底层操作系统原语子系统)
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) 与 [`docs/02_architecture/06_MODULE_GOVERNANCE_SPEC.md`](../../docs/02_architecture/06_MODULE_GOVERNANCE_SPEC.md)
5
5
  > **守卫机制**: `scripts/verify_directory_indices.py` (100% 物理条目索引覆盖)
6
6
 
@@ -12,8 +12,8 @@ import re
12
12
  from pathlib import Path
13
13
 
14
14
  VERSION_ENV = "BUGX_VERSION"
15
- VERSION_TOKEN = "0.1.2"
16
- _DEFAULT_VERSION = "0.1.2"
15
+ VERSION_TOKEN = "0.1.4"
16
+ _DEFAULT_VERSION = "0.1.4"
17
17
  _VERSION_RE = re.compile(r"^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$")
18
18
 
19
19
 
@@ -88,10 +88,34 @@ def bump_build_id(root: Path | None = None) -> int:
88
88
  return next_id
89
89
 
90
90
 
91
+ def is_dev_mode(root: Path | None = None) -> bool:
92
+ """是否处于 dev / alpha 开发模式。正式版返回 False。"""
93
+ if os.environ.get("BUGX_DEV") in ("1", "true", "yes", "on"):
94
+ return True
95
+ env = os.environ.get("BUGX_ENV", "").strip().lower()
96
+ if env in ("dev", "development", "local", "test"):
97
+ return True
98
+ meta_path = _resolve_metadata_path(root)
99
+ if meta_path.is_file():
100
+ try:
101
+ content = meta_path.read_text(encoding="utf-8")
102
+ m_chan = re.search(r"^bugx_channel:\s*[\"']?([A-Za-z0-9_-]+)", content, re.M)
103
+ m_mark = re.search(r"^bugx_marker:\s*[\"']?([A-Za-z0-9_-]+)", content, re.M)
104
+ channel = m_chan.group(1).lower() if m_chan else "stable"
105
+ marker = m_mark.group(1).lower() if m_mark else "stable"
106
+ if channel != "stable" or marker in ("dev", "alpha"):
107
+ return True
108
+ except OSError:
109
+ pass
110
+ return False
111
+
112
+
91
113
  def get_full_version_string(root: Path | None = None) -> str:
92
- """返回标准版本与 Build ID 组合字符串,例如 0.1.1+build.627。"""
93
- bid = get_build_id(root)
94
- return f"{BASE_VERSION}+build.{bid}"
114
+ """返回标准版本展示字符串。正式版(Stable)不带 build ID;仅 dev 模式携带。"""
115
+ if is_dev_mode(root):
116
+ bid = get_build_id(root)
117
+ return f"{BASE_VERSION}+build.{bid}"
118
+ return BASE_VERSION
95
119
 
96
120
 
97
121
  __all__ = [
@@ -101,5 +125,6 @@ __all__ = [
101
125
  "bump_build_id",
102
126
  "get_build_id",
103
127
  "get_full_version_string",
128
+ "is_dev_mode",
104
129
  "resolve_base_version",
105
130
  ]
@@ -91,7 +91,7 @@ flowchart TD
91
91
  | `startup_gates.py` | 启动前置安全门禁(文件树白名单、脏工作区检查、权限拦截) | `verify_startup_gates` |
92
92
  | `startup_interaction.py` | 交互式问答决策引擎,根据终端能力与配置解析交互模式 | `resolve_startup_interaction` |
93
93
  | `verify_loop.py` | 独立验证员盲审输入包构造、Anti-Gaming 校验与报错驱动 PoC 自纠错闭环 | `build_verify_bundle`, `execute_verify_attempt`, `run_verification_loop` |
94
- | `startup_version_gate.py` | 版本硬门禁校验器,确保运行时版本严格等于 `0.1.2` 绝不漂移 | `assert_version_integrity` |
94
+ | `startup_version_gate.py` | 版本硬门禁校验器,确保运行时版本严格等于 `0.1.4` 绝不漂移 | `assert_version_integrity` |
95
95
  | `supervisor_bridge.py` | Supervisor 模块间解耦桥接层,提供轻量化调用门面 | `SupervisorBridge` |
96
96
  | `supervisor_coverage.py` | 覆盖率生命周期继承器,支持空闲历史会话继承与动态分发 | `SupervisorCoverageSync` |
97
97
  | `supervisor_degraded.py` | 降级容灾与探针就地自愈控制器,无损处理缺失依赖与环境 | `SupervisorDegradedCoordinator` |
@@ -103,7 +103,7 @@ flowchart TD
103
103
 
104
104
  ## 3. 核心设计契约与公理 (Design Axioms)
105
105
 
106
- 1. **版本绝对固化公理**:`startup_version_gate.py` 必须在任何业务逻辑启动前执行,基线版本严格锁定在 `0.1.2`,杜绝任何环境版本漂移。
106
+ 1. **版本绝对固化公理**:`startup_version_gate.py` 必须在任何业务逻辑启动前执行,基线版本严格锁定在 `0.1.4`,杜绝任何环境版本漂移。
107
107
  2. **状态机单向流转与幂等性**:生命周期从 `Pre` $\rightarrow$ `Round` $\rightarrow$ `Worker` $\rightarrow$ `Judge` $\rightarrow$ `Settlement` $\rightarrow$ `Post` 严格单向流动,禁止逆流操作;重试必须走显式的轮次迭代(`advance_round_lifecycle`)。
108
108
  3. **证据零伪造公理**:在 `findings_adjudication.py` 与 `candidate_revalidation.py` 中,所有缺陷判定必须有可执行的反事实测试证据,严禁仅凭模型推理文本定性。
109
109
  4. **工作树物理安全红线**:`post_dry_run.py` 与 `post_commit.py` 严格遵守工作树保护宪法,未授权时绝对禁止覆盖用户未暂存的修改。
@@ -240,8 +240,8 @@ def version_marker(path: Path) -> str | None:
240
240
  if not match:
241
241
  return None
242
242
  value = match.group(1)
243
- if value == "0.1.2":
244
- value = os.environ.get("BUGX_VERSION", "0.1.2")
243
+ if value == "0.1.4":
244
+ value = os.environ.get("BUGX_VERSION", "0.1.4")
245
245
  return value
246
246
 
247
247
  def startup_release_version(value: object) -> tuple[int, int, int] | None:
@@ -992,6 +992,8 @@ def host_entry_gate() -> int:
992
992
  print(f"[launch_bugx] ✗ 宿主入口就绪性检查失败({type(exc).__name__}):{exc}")
993
993
  return RESTART_REQUIRED
994
994
  if status.get("ready"):
995
+ for warning in status.get("warnings") or []:
996
+ print(f"[launch_bugx] ⚠ {warning}")
995
997
  return 0
996
998
  print("[launch_bugx] ✗ 需要重启宿主:宿主侧入口(MCP + skill)未就绪——"
997
999
  + str(status.get("reason") or "未知原因"))
@@ -1056,8 +1058,6 @@ def supervisor_mcp_gate(*, review_mode: str | None,
1056
1058
  * ``"restart_required"`` —— 配置已写入/已存在但当前宿主未加载 ⇒ 必须重启宿主;
1057
1059
  * ``"blocked"`` —— 需要用户/宿主决策或安装未完成。
1058
1060
  """
1059
- if review_mode != "mcp-auto":
1060
- return "ok"
1061
1061
  # [BEGIN DEV_ONLY: FAST_VERIFICATION_MCP_GATE]
1062
1062
  try:
1063
1063
  from core.runtime.interaction import try_get_preset_runtime_config
@@ -1071,27 +1071,20 @@ def supervisor_mcp_gate(*, review_mode: str | None,
1071
1071
  if preset_cfg.get("supervisor_mcp") in {"manual", "skip"}:
1072
1072
  return "ok"
1073
1073
  # [END DEV_ONLY: FAST_VERIFICATION_MCP_GATE]
1074
+
1074
1075
  status = _supervisor_mcp_status()
1075
- if status is None:
1076
+ # 强制重启门禁:若项目已配置 Supervisor MCP 但当前宿主会话未加载该工具链(stale),
1077
+ # 宿主进程无法动态感知新配置,探活绝不能替代重启,必须阻断并强制要求重启宿主。
1078
+ if status is not None and _mcp_session_is_stale(status):
1079
+ host = str(status.get("host") or "当前宿主")
1080
+ print(f"[launch_bugx] ✗ 必须强制重启宿主:{host} 已配置 Supervisor MCP,但当前会话尚未加载该 MCP 工具链。")
1081
+ print(" 宿主进程(IDE/终端)不支持动态热重载配置,必须【重载窗口 / 重启宿主会话】后再启动 BugX。")
1082
+ return "restart_required"
1083
+
1084
+ if review_mode != "mcp-auto":
1076
1085
  return "ok"
1077
- # A configured-but-not-loaded session is handled by the final
1078
- # ``startup_action`` gate below. Do not present the older install/manual
1079
- # gate here, otherwise the host can silently choose manual review and move
1080
- # on to the polling question (the bug this gate is meant to prevent).
1081
- if _mcp_session_is_stale(status):
1082
- # 尝试快速 stdio 活体探活(A1 自愈机制)
1083
- try:
1084
- from core.supervisor import supervisor_host
1085
- probe_result = supervisor_host.probe_builtin_mcp_session(resolve_project_root(), deadline=None)
1086
- if not probe_result.get("error"):
1087
- os.environ[supervisor_host.MCP_SESSION_PROOF_ENV] = json.dumps(probe_result, ensure_ascii=False)
1088
- return "ok"
1089
- except Exception:
1090
- pass
1091
- if autonomous:
1092
- print("[launch_bugx] ✗ 需要重启宿主:Supervisor MCP 已配置但当前宿主未加载且探活未通过;"
1093
- "支持使用 stdio JSON-RPC 等效通道驱动,或重启宿主会话后重试。")
1094
- return "restart_required"
1086
+
1087
+ if status is None:
1095
1088
  return "ok"
1096
1089
  if autonomous:
1097
1090
  # The installer is already constrained to the BugX-managed host
@@ -1100,7 +1093,7 @@ def supervisor_mcp_gate(*, review_mode: str | None,
1100
1093
  if not _install_supervisor_mcp(status):
1101
1094
  print("[launch_bugx] 自治模式已停止:Supervisor MCP 安装失败(需宿主重启后重试)。")
1102
1095
  return "restart_required"
1103
- print("[launch_bugx] Supervisor MCP 配置已写入;需要宿主重新启动后才能加载。")
1096
+ print("[launch_bugx] ✗ 必须强制重启宿主:Supervisor MCP 配置已写入;宿主重新启动后才能加载。")
1104
1097
  return "restart_required"
1105
1098
  choice = _prompt_supervisor_mcp(status, allow_manual=False)
1106
1099
  if choice is None:
@@ -1133,7 +1126,7 @@ def supervisor_mcp_gate(*, review_mode: str | None,
1133
1126
  return "blocked"
1134
1127
  if choice == "install":
1135
1128
  _install_supervisor_mcp(status)
1136
- print("[launch_bugx] Supervisor MCP 配置已写入;需要宿主重新启动后才能加载。")
1129
+ print("[launch_bugx] ✗ 必须强制重启宿主:Supervisor MCP 配置已写入;宿主重新启动后才能加载。")
1137
1130
  return "restart_required"
1138
1131
  if choice == "later":
1139
1132
  print("[launch_bugx] Supervisor MCP 安装已延后,本轮启动停止。")
@@ -185,11 +185,13 @@ def degraded_item_transient(item: Mapping[str, Any]) -> bool:
185
185
 
186
186
 
187
187
  def degraded_item_critical(item: Mapping[str, Any]) -> bool:
188
- """能力是否 critical:以描述符机器声明为准,缺失时才回落到 ``kind=mcp`` 猜测。"""
188
+ """能力是否 critical:codebase-memory 为必装核心能力,其余以描述符或 mcp 判定。"""
189
+ name = str(item.get("name", "")).casefold()
190
+ if "codebase-memory" in name or "tree-sitter" in name:
191
+ return True
189
192
  declared = item.get("critical")
190
193
  if isinstance(declared, bool):
191
194
  return declared
192
- name = str(item.get("name", "")).casefold()
193
195
  return bool(item.get("kind") == "mcp" or "mcp" in name)
194
196
 
195
197
 
@@ -370,12 +372,12 @@ def auto_provision_accelerators(
370
372
  if isinstance(probe_report, dict) else "invalid-report"
371
373
  )
372
374
  print(
373
- f"[launch_bugx] Codebase Memory 复核未 READY({failed}),保留降级选项"
375
+ f"[launch_bugx] Codebase Memory 必装组件未 READY({failed}),将阻断放行"
374
376
  )
375
377
  except Exception as exc:
376
378
  print(
377
- "[launch_bugx] Codebase Memory 自愈/复核异常 "
378
- f"({type(exc).__name__}),保留降级选项"
379
+ "[launch_bugx] Codebase Memory 必装组件自愈/复核异常 "
380
+ f"({type(exc).__name__}),将阻断放行"
379
381
  )
380
382
 
381
383
  # 2. bugx-supervisor / 宿主 MCP 自动就地配置注入
@@ -1,6 +1,6 @@
1
1
  # BugX Ledger (攻防复盘账本与错题经验库)
2
2
 
3
- > **版本契约**: `0.1.2` | **所属分层**: `Layer 3: 并发协调、智能体编排与账本`
3
+ > **版本契约**: `0.1.4` | **所属分层**: `Layer 3: 并发协调、智能体编排与账本`
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