bugx-cli 0.1.4 → 0.1.6

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 (127) hide show
  1. package/README.md +89 -210
  2. package/core/README.md +1 -1
  3. package/core/agent/agent_execution.py +7 -0
  4. package/core/agent/agent_targets.py +5 -1
  5. package/core/agent/agent_workspace.py +10 -2
  6. package/core/autonomous_cve/run_fault_matrix.py +692 -0
  7. package/core/autonomous_cve/run_oss_cve_exploit_verify.py +608 -0
  8. package/core/autonomous_cve/run_six_worker_penetration.py +382 -0
  9. package/core/autonomous_cve/verifier.py +5 -7
  10. package/core/bugx.md +1 -1
  11. package/core/bugx_paths.py +2 -2
  12. package/core/bundled_docs/OVERVIEW.md +70 -236
  13. package/core/bundled_docs/README.md +2 -2
  14. package/core/bundled_docs/README_EN.md +67 -211
  15. package/core/bundled_docs/ai/01_AI_REFERENCE.md +11 -6
  16. package/core/bundled_docs/ai/02_AI_USAGE.md +1 -1
  17. package/core/bundled_docs/ai/03_AI_COMMANDS.md +1 -1
  18. package/core/bundled_docs/guides/01_USER_GUIDE.md +5 -5
  19. package/core/bundled_docs/guides/02_COMMANDS.md +3 -3
  20. package/core/bundled_docs/guides/03_TROUBLESHOOTING.md +4 -4
  21. package/core/bundled_docs/guides/05_HOST_MATRIX_AND_DISPATCH.md +4 -2
  22. package/core/bundled_docs/hosts/bugx_SKILL.md +2 -2
  23. package/core/bundled_docs/hosts/platform_bugx_SKILL.md +2 -2
  24. package/core/bundled_docs/manifest.json +22 -22
  25. package/core/bundled_docs/reference/01_ENVIRONMENT_VARIABLES.md +1 -0
  26. package/core/bundled_docs/reference/04_REPOSITORY_TOPOLOGY.md +1 -1
  27. package/core/cloud_sync/flywheel_client.py +89 -0
  28. package/core/contracts/README.md +1 -1
  29. package/core/contracts/bugx-runtime-contract.md +1 -1
  30. package/core/contracts/bugx-worker.md +1 -1
  31. package/core/coverage/coverage_ai_review.py +15 -11
  32. package/core/coverage/coverage_bootstrap.py +18 -13
  33. package/core/coverage/coverage_discovery.py +1 -1
  34. package/core/coverage/coverage_gate.py +12 -2
  35. package/core/coverage/coverage_manifest.py +1 -1
  36. package/core/coverage/coverage_validate.py +5 -3
  37. package/core/dev_harness/interaction_preset.py +1 -1
  38. package/core/engine-integrity.json +183 -163
  39. package/core/host_acp/README.md +4 -0
  40. package/core/host_acp/agnescode.py +128 -0
  41. package/core/host_runtime/README.md +3 -0
  42. package/core/host_runtime/adapters.py +45 -6
  43. package/core/host_runtime/autonomous_runner.py +3 -2
  44. package/core/host_runtime/host_registry.py +7 -1
  45. package/core/hosts/README.md +4 -0
  46. package/core/hosts/__init__.py +1 -0
  47. package/core/hosts/agnescode.py +415 -0
  48. package/core/hosts/base.py +1 -0
  49. package/core/hosts/claude.py +6 -0
  50. package/core/hosts/cline.py +6 -0
  51. package/core/hosts/codex.py +10 -1
  52. package/core/hosts/kimi.py +6 -4
  53. package/core/hosts/opencode.py +12 -4
  54. package/core/hosts/zcode.py +6 -0
  55. package/core/infra/README.md +1 -1
  56. package/core/infra/build_info.py +2 -2
  57. package/core/infra/python_runtime.py +4 -1
  58. package/core/launch_phases/README.md +2 -2
  59. package/core/launch_phases/finding_confirm_phase.py +1 -1
  60. package/core/launch_phases/semantic_recon.py +3 -19
  61. package/core/launch_phases/startup_gates.py +10 -1
  62. package/core/launch_phases/startup_version_gate.py +2 -2
  63. package/core/launch_phases/verify_loop.py +3 -19
  64. package/core/ledger/README.md +1 -1
  65. package/core/ledger/finding_confirmation.py +1 -1
  66. package/core/ledger/finding_verification.py +2 -20
  67. package/core/ledger/fp_ledger.py +3 -19
  68. package/core/ledger/life_ledger.py +7 -33
  69. package/core/ledger/schema.py +1 -1
  70. package/core/locales/en-US.json +2 -0
  71. package/core/locales/zh-CN.json +2 -0
  72. package/core/mcp_handlers/supervisor_handlers.py +34 -2
  73. package/core/mcp_handlers/telemetry_handlers.py +32 -0
  74. package/core/mcp_handlers/tool_table.py +34 -0
  75. package/core/mcp_runtime_support/common.py +6 -0
  76. package/core/mcp_runtime_support/environment.py +82 -23
  77. package/core/metadata.txt +1 -1
  78. package/core/planning/README.md +1 -1
  79. package/core/planning/target_sandbox_manager.py +2 -0
  80. package/core/probes/mobile_probe.py +1 -0
  81. package/core/probes/sast_probe.py +1 -1
  82. package/core/probes/sca_scanner.py +1 -1
  83. package/core/project_profiler/constants.py +1 -1
  84. package/core/retrieval/README.md +1 -1
  85. package/core/retrieval/symbol_index.py +229 -53
  86. package/core/retrieval/universal_code_matcher.py +1 -0
  87. package/core/runtime/README.md +1 -1
  88. package/core/runtime/daemon_runner.py +3 -2
  89. package/core/runtime/mining_quality_framework.py +2 -1
  90. package/core/runtime/project_init.py +1 -1
  91. package/core/runtime/scenario_eval.py +5 -2
  92. package/core/skills/bugx_mcp_server.py +9 -0
  93. package/core/skills/mcp_session_proof.py +3 -31
  94. package/core/supervisor/README.md +1 -1
  95. package/core/supervisor/finding_commit.py +3 -24
  96. package/core/supervisor/task_scheduler.py +5 -2
  97. package/core/supervisor/worker_execution.py +5 -0
  98. package/core/supervisor/worker_handoff.py +2 -2
  99. package/docs/07_distribution/01_README_NPM.md +89 -210
  100. package/ecosystem/integrations/dsh/mcp/package.json +2 -2
  101. package/ecosystem/integrations/dsh/ui/package.json +1 -1
  102. package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +3 -3
  103. package/ecosystem/integrations/opencode/mcp-lock.json +1 -1
  104. package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
  105. package/ecosystem/integrations/qoder/connector-meta.json +1 -1
  106. package/ecosystem/integrations/workbuddy/connector-meta.json +1 -1
  107. package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +1 -1
  108. package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +1 -1
  109. package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +1 -1
  110. package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +1 -1
  111. package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +2 -2
  112. package/interfaces/cli/bugx_cli/__init__.py +1 -1
  113. package/interfaces/cli/bugx_cli/cli.py +15 -0
  114. package/interfaces/cli/bugx_cli/commands/agent.py +18 -0
  115. package/interfaces/cli/bugx_cli/commands/audit.py +5 -6
  116. package/interfaces/cli/bugx_cli/commands/doctor.py +1 -1
  117. package/interfaces/cli/bugx_cli/commands/lifecycle.py +1 -1
  118. package/interfaces/cli/bugx_cli/commands/patch.py +5 -1
  119. package/interfaces/cli/bugx_cli/commands/plugin.py +31 -2
  120. package/interfaces/cli/bugx_cli/commands/plugin_claude.py +2 -2
  121. package/interfaces/cli/bugx_cli/host_adapters.py +167 -1
  122. package/interfaces/cli/bugx_cli/hosts/registry.py +33 -1
  123. package/interfaces/cli/bugx_cli/infra/engine_installer.py +4 -4
  124. package/interfaces/cli/bugx_cli/infra/host_sync.py +1 -1
  125. package/package.json +1 -1
  126. package/scripts/sync-version.mjs +1 -1
  127. package/skills/platform/bugx/SKILL.md +2 -2
@@ -24,6 +24,8 @@ import time
24
24
  from pathlib import Path
25
25
  from typing import Any, Callable, Mapping, Sequence
26
26
 
27
+ import core.secure_atomic as secure_atomic
28
+
27
29
  OVERLAY_SCHEMA_VERSION = 1
28
30
  MAX_FIELD_CHARS = 200
29
31
  MAX_CONTEXT_FILES = 24
@@ -59,26 +61,8 @@ def _sha256_bytes(data: bytes) -> str:
59
61
 
60
62
 
61
63
  def _atomic_write_json(path: Path, payload: Mapping[str, Any]) -> None:
62
- path.parent.mkdir(parents=True, exist_ok=True, mode=0o700)
63
64
  raw = json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True).encode("utf-8")
64
- fd, tmp_name = tempfile.mkstemp(prefix=f".{path.name}.", dir=str(path.parent))
65
- try:
66
- os.fchmod(fd, 0o600)
67
- with os.fdopen(fd, "wb") as handle:
68
- handle.write(raw)
69
- handle.flush()
70
- os.fsync(handle.fileno())
71
- os.replace(tmp_name, path)
72
- except BaseException:
73
- try:
74
- os.close(fd)
75
- except OSError:
76
- pass
77
- try:
78
- os.unlink(tmp_name)
79
- except OSError:
80
- pass
81
- raise
65
+ secure_atomic.atomic_write_bytes(path, raw, mode=0o600, parent_mode=0o700)
82
66
 
83
67
 
84
68
  def _sanitize_text(value: object, *, max_len: int = MAX_FIELD_CHARS) -> tuple[str, bool]:
@@ -712,7 +712,9 @@ def _install_explicit_coverage_manifest(root: Path) -> int | None:
712
712
  coverage_gate = None
713
713
  if coverage_gate is not None:
714
714
  try:
715
- gate_errors = coverage_gate.startup_gate_errors(resolved_root, manifest)
715
+ gate_errors = coverage_gate.startup_gate_errors(
716
+ resolved_root, manifest, explicit_scope=True
717
+ )
716
718
  except (OSError, ValueError, RuntimeError) as exc:
717
719
  print(f"[launch_bugx] ✗ 显式覆盖清单预检失败: {exc}")
718
720
  return 1
@@ -727,6 +729,13 @@ def _install_explicit_coverage_manifest(root: Path) -> int | None:
727
729
  try:
728
730
  destination.parent.mkdir(parents=True, exist_ok=True)
729
731
  payload = manifest.read_bytes()
732
+ if module_coverage.DISCOVERY_METADATA_START.encode("utf-8") not in payload:
733
+ meta_header = (
734
+ f"{module_coverage.DISCOVERY_METADATA_START}\n"
735
+ '{"status": "complete", "discovery_mode": "explicit", "coverage_confidence": "high", "discovery_errors": []}\n'
736
+ f"{module_coverage.DISCOVERY_METADATA_END}\n\n"
737
+ ).encode("utf-8")
738
+ payload = meta_header + payload
730
739
  if destination.is_file():
731
740
  existing = destination.read_bytes()
732
741
  if existing != payload:
@@ -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.4":
244
- value = os.environ.get("BUGX_VERSION", "0.1.4")
243
+ if value == "0.1.6":
244
+ value = os.environ.get("BUGX_VERSION", "0.1.6")
245
245
  return value
246
246
 
247
247
  def startup_release_version(value: object) -> tuple[int, int, int] | None:
@@ -28,6 +28,8 @@ import time
28
28
  from pathlib import Path
29
29
  from typing import Any, Callable, Mapping, Sequence
30
30
 
31
+ import core.secure_atomic as secure_atomic
32
+
31
33
  from core.ledger.finding_verification import (
32
34
  RETRYABLE_FAILURE_CODES,
33
35
  VerificationDiagnostic,
@@ -68,26 +70,8 @@ def _fp_slug(fingerprint: str) -> str:
68
70
 
69
71
 
70
72
  def _atomic_write_json(path: Path, payload: Mapping[str, Any]) -> None:
71
- path.parent.mkdir(parents=True, exist_ok=True, mode=0o700)
72
73
  data = json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True).encode("utf-8")
73
- fd, tmp_name = tempfile.mkstemp(prefix=f".{path.name}.", dir=str(path.parent))
74
- try:
75
- os.fchmod(fd, 0o600)
76
- with os.fdopen(fd, "wb") as handle:
77
- handle.write(data)
78
- handle.flush()
79
- os.fsync(handle.fileno())
80
- os.replace(tmp_name, path)
81
- except BaseException:
82
- try:
83
- os.close(fd)
84
- except OSError:
85
- pass
86
- try:
87
- os.unlink(tmp_name)
88
- except OSError:
89
- pass
90
- raise
74
+ secure_atomic.atomic_write_bytes(path, data, mode=0o600, parent_mode=0o700)
91
75
 
92
76
 
93
77
  def strip_runner_wrapper(code: str) -> str:
@@ -1,6 +1,6 @@
1
1
  # BugX Ledger (攻防复盘账本与错题经验库)
2
2
 
3
- > **版本契约**: `0.1.4` | **所属分层**: `Layer 3: 并发协调、智能体编排与账本`
3
+ > **版本契约**: `0.1.6` | **所属分层**: `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
 
@@ -251,7 +251,7 @@ def reproduction_not_executable(value: object) -> bool:
251
251
  try:
252
252
  result = subprocess.run(
253
253
  ["bash", "-n", "-c", text], capture_output=True, text=True,
254
- timeout=5, check=False,
254
+ encoding="utf-8", errors="replace", timeout=5, check=False,
255
255
  )
256
256
  except (OSError, subprocess.SubprocessError):
257
257
  return False
@@ -22,6 +22,7 @@ from dataclasses import dataclass
22
22
  from pathlib import Path
23
23
  from typing import Any, Mapping, Sequence
24
24
 
25
+ import core.secure_atomic as secure_atomic
25
26
  from core.supervisor.worker_execution import run_bounded, WorkerExecutionError
26
27
 
27
28
 
@@ -255,26 +256,7 @@ def _result_record(result: Any, *, execution_id: str, case: str, argv: Sequence[
255
256
 
256
257
 
257
258
  def _atomic_json(path: Path, payload: Mapping[str, object]) -> None:
258
- path.parent.mkdir(parents=True, exist_ok=True, mode=0o700)
259
- raw = _canonical(payload)
260
- descriptor, temporary = tempfile.mkstemp(prefix=f".{path.name}.", dir=str(path.parent))
261
- try:
262
- os.fchmod(descriptor, 0o600)
263
- with os.fdopen(descriptor, "wb") as handle:
264
- handle.write(raw)
265
- handle.flush()
266
- os.fsync(handle.fileno())
267
- os.replace(temporary, path)
268
- except BaseException:
269
- try:
270
- os.close(descriptor)
271
- except OSError:
272
- pass
273
- try:
274
- os.unlink(temporary)
275
- except OSError:
276
- pass
277
- raise
259
+ secure_atomic.atomic_write_bytes(path, _canonical(payload), mode=0o600, parent_mode=0o700)
278
260
 
279
261
 
280
262
  def verify_finding(root: Path, finding: Mapping[str, object], recipe: Mapping[str, object] | VerificationRecipe,
@@ -20,6 +20,8 @@ import time
20
20
  from pathlib import Path
21
21
  from typing import Any, Mapping, Sequence
22
22
 
23
+ import core.secure_atomic as secure_atomic
24
+
23
25
  LEDGER_SCHEMA_VERSION = 1
24
26
  ALLOWED_FP_REJECTION_CLASSES = frozenset({
25
27
  "not_reproducible",
@@ -72,26 +74,8 @@ def ledger_path(root: Path) -> Path:
72
74
 
73
75
 
74
76
  def _atomic_write_json(path: Path, payload: Mapping[str, Any]) -> None:
75
- path.parent.mkdir(parents=True, exist_ok=True, mode=0o700)
76
77
  raw = json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True).encode("utf-8")
77
- fd, tmp_name = tempfile.mkstemp(prefix=f".{path.name}.", dir=str(path.parent))
78
- try:
79
- os.fchmod(fd, 0o600)
80
- with os.fdopen(fd, "wb") as handle:
81
- handle.write(raw)
82
- handle.flush()
83
- os.fsync(handle.fileno())
84
- os.replace(tmp_name, path)
85
- except BaseException:
86
- try:
87
- os.close(fd)
88
- except OSError:
89
- pass
90
- try:
91
- os.unlink(tmp_name)
92
- except OSError:
93
- pass
94
- raise
78
+ secure_atomic.atomic_write_bytes(path, raw, mode=0o600, parent_mode=0o700)
95
79
 
96
80
 
97
81
  def load_fp_ledger(root: Path) -> dict[str, Any]:
@@ -34,6 +34,8 @@ from contextlib import contextmanager
34
34
  from dataclasses import dataclass
35
35
  from pathlib import Path
36
36
 
37
+ import core.secure_atomic as secure_atomic
38
+
37
39
  try:
38
40
  import fcntl
39
41
  except ImportError: # pragma: no cover - Windows
@@ -259,39 +261,11 @@ def _fsync_directory(directory: Path) -> None:
259
261
 
260
262
  def atomic_write_json(path: str | os.PathLike[str], data: Mapping[str, Any]) -> None:
261
263
  """Atomically replace *path* with JSON, flushing file and directory metadata."""
262
- target = Path(path)
263
- directory = target.parent if target.parent != Path("") else Path(".")
264
- directory.mkdir(parents=True, exist_ok=True)
265
- temporary: Path | None = None
266
- descriptor, temporary_name = tempfile.mkstemp(
267
- prefix=f".{target.name}.", suffix=".tmp", dir=str(directory)
268
- )
269
- temporary = Path(temporary_name)
270
- try:
271
- os.fchmod(descriptor, 0o600)
272
- with os.fdopen(descriptor, "w", encoding="utf-8") as handle:
273
- descriptor = -1
274
- json.dump(
275
- data,
276
- handle,
277
- ensure_ascii=False,
278
- sort_keys=True,
279
- separators=(",", ":"),
280
- )
281
- handle.write("\n")
282
- handle.flush()
283
- os.fsync(handle.fileno())
284
- os.replace(temporary, target)
285
- temporary = None
286
- _fsync_directory(directory)
287
- finally:
288
- if descriptor != -1:
289
- os.close(descriptor)
290
- if temporary is not None:
291
- try:
292
- temporary.unlink()
293
- except FileNotFoundError:
294
- pass
264
+ payload = (
265
+ json.dumps(data, ensure_ascii=False, sort_keys=True, separators=(",", ":"))
266
+ + "\n"
267
+ ).encode("utf-8")
268
+ secure_atomic.atomic_write_bytes(path, payload, mode=0o600)
295
269
 
296
270
 
297
271
  def _lock_for(path: Path) -> threading.RLock:
@@ -384,7 +384,7 @@ def _journal_mode_lock(db: Path) -> Iterator[None]:
384
384
  thread_acquired = True
385
385
  if not stat.S_ISREG(os.fstat(descriptor).st_mode):
386
386
  raise LessonLedgerError("SQLite journal-mode 锁必须是普通文件")
387
- if os.name != "nt":
387
+ if hasattr(os, "fchmod"):
388
388
  os.fchmod(descriptor, 0o600)
389
389
  deadline = time.monotonic() + 10.0
390
390
  if _fcntl is not None:
@@ -434,6 +434,7 @@
434
434
  "host.entry.section.workbuddy": "\n\n## WorkBuddy AI adaptation (mandatory)\n\nThis entry is loaded as a WorkBuddy Skill: do not run `bugx install`, do not guess gate answers, and never treat plain text as a completed user selection. The WorkBuddy desktop enables it through Skill/plugin management; code-development mode reads this entry from the project `.workbuddy/` (or compatible `.codebuddy/`) configuration.\n",
435
435
  "host.entry.section.qoder": "\n\n## Qoder native interaction adaptation (mandatory)\n\nThe launcher must explicitly use `--host qoder` to write the host into the current runtime; never infer the host from project configuration. Use the `ask_question` provided by the current Qoder session (or an equivalent structured user-selection control); execute the option's unique `value` and controlled `action`, and never guess an action from a label.\n",
436
436
  "host.entry.section.trea": "\n\n## Trea native interaction adaptation (mandatory)\n\nPresent interaction decisions with Trea's `AskUserQuestion` tool, one question at a time; execute the unique `value` and controlled `action` of the selected option, and never guess an action from a Chinese label.\n",
437
+ "host.entry.section.copilot": "\n\n## GitHub Copilot native interaction adaptation (mandatory)\n\nThis entry adapts to GitHub Copilot Agent mode and Copilot Chat instruction specifications. It is auto-loaded via project-level `.github/agents/bugx.agent.md` and `.github/copilot-instructions.md`. When human decision-making is required, use Copilot's native structured control; execute the option's unique `value` and controlled `action`. MCP configuration is written to `.vscode/mcp.json` and `.mcp.json` by the installer, and `bugx-supervisor` and the worker must both be enabled.\n",
437
438
  "host.entry.section.qoder.basic": "",
438
439
  "host.entry.section.cline": "\n\n## Cline native interaction adaptation (mandatory)\n\nThe launcher must write the host into the current session runtime via `--host cline`; never let a project's `opencode.json` infer the host. Use the `ask_question` provided by the current Cline session (or an equivalent structured user-selection control); execute the option's unique `value` and controlled `action`. This entry is loaded by the Cline project-level Skill (`.cline/skills/bugx/SKILL.md`, discovered automatically by Cline or triggered by `/bugx`); the Cline desktop enters through the current workspace's BugX Skill, while Cline CLI uses `cline <prompt>`, headless autonomy is carried by the CLI's JSON/headless mode for prompts and session recovery, and `cline --acp` is an ACP service endpoint that must not be run directly as a one-shot prompt command. The installer writes Cline MCP into `mcpServers` in the Cline data-directory file `<CLINE_DATA_DIR>/settings/cline_mcp_settings.json` (default `~/.cline/data/settings/cline_mcp_settings.json`); Cline 3.x has no workspace-level MCP scope, so a project `.cline/mcp.json` is never loaded. `bugx-supervisor` and the worker must both exist and be enabled — the Skill file cannot replace MCP. Cline does not support BugX's `Task(subagent_type=\"bugx-worker\")` dispatch contract; the desktop's built-in research sub-agent lacks worker write and MCP permissions, and the CLI's own Agent/Team interface is not equivalent to that Task contract. Interactive single sessions therefore stay serial with one claim at a time: run `bugx engine --root . workers --count 1`, then have the current session complete worker-start, heartbeat/tool_call, and checkpoint through `bugx-supervisor-worker`, and claim the next unit only after verifying a valid checkpoint. Multi-process CLI/autonomous execution uses `bugx autonomous --host cline --workers N`, or the workers' explicit `--execute`; the runtime context atomically writes host/execute/worker_capacity into the current project session and switches to a bounded 2-6 process pool. Each claim runs in `<artifact_root>/.cline_data`, with `CLINE_DATA_DIR` and `--data-dir` injected, loading only `bugx-supervisor-worker` (`--role worker`) and `bugx-docs` — never the controlling `bugx-supervisor`. The pool follows Supervisor adaptive slots using a sliding window and the runtime context's `stagger_seconds` to refill in a staggered way; a claim is reclaimed on timeout, abnormal exit, or missing persisted checkpoint, and only a valid Supervisor checkpoint counts as success. During the mine stage the shared source is read-only, and PoCs and evidence may only be written into the claim's artifact_root.\n",
439
440
  "host.entry.header.opencode": "# BugX\n\nThis is BugX's native OpenCode entry. Read the global engine protocol first: load the global protocol via `bugx engine path --name bugx-runtime-contract.md` and `bugx engine path --name bugx-quick.md`, and follow the lifetime, Supervisor, evidence, and reporting protocols in them.\n\nThis entry only hands the task to the current OpenCode; the CLI installs resources and does not run audits. Public agent template source: `{source}`.\n",
@@ -448,6 +449,7 @@
448
449
  "host.entry.header.qoder": "# BugX\n\nThis is BugX's Qoder AI entry. Read the global engine protocol first: load the global protocol via `bugx engine path --name bugx-runtime-contract.md` and `bugx engine path --name bugx-quick.md`, and follow the lifetime, Supervisor, evidence, and reporting protocols in them.\n\nThis entry only hands the task to the current Qoder AI; the CLI installs resources and does not run audits. Public agent template source: `{source}`.\n",
449
450
  "host.entry.header.trea": "# BugX\n\nThis is BugX's Trea entry. Read the global engine protocol first: load the global protocol via `bugx engine path --name bugx-runtime-contract.md` and `bugx engine path --name bugx-quick.md`, and follow the lifetime, Supervisor, evidence, and reporting protocols in them.\n\nThis entry only hands the task to the current Trea; the CLI installs resources and does not run audits. Public agent template source: `{source}`.\n",
450
451
  "host.entry.header.funide": "# BugX\n\nThis is BugX's FunIDE entry. Read the global engine protocol first: load the global protocol via `bugx engine path --name bugx-runtime-contract.md` and `bugx engine path --name bugx-quick.md`, and follow the lifetime, Supervisor, evidence, and reporting protocols in them.\n\nThis entry only hands the task to the current FunIDE; the CLI installs resources and does not run audits. Public agent template source: `{source}`.\n",
452
+ "host.entry.header.copilot": "# BugX\n\nThis is BugX's native GitHub Copilot entry. Read the global engine protocol first: load the global protocol via `bugx engine path --name bugx-runtime-contract.md` and `bugx engine path --name bugx-quick.md`, and follow the lifetime, Supervisor, evidence, and reporting protocols in them.\n\nThis entry only hands the task to the current GitHub Copilot; the CLI installs resources and does not run audits. Public agent template source: `{source}`.\n",
451
453
  "host.entry.body.zcode_worker": "\n# BugX Worker — ZCode concurrent worker sub-agent\n\nYou are BugX's concurrent worker sub-agent, dispatched in parallel within a Round by the main agent through ZCode's subagent capability (`subagent_type=bugx-worker`; in plugin form `bugx:bugx-worker`). First read and obey the following global engine protocols via `bugx engine path --name <file>`; they are the only authoritative entities and this entry does not copy their content:\n\n- `bugx engine path --name bugx-worker.md`: worker unit-level execution rules (four start-up steps, mining discipline, case-filing oracle, hard evidence gate, checkpoint submission);\n- `bugx engine path --name bugx-runtime-contract.md` and `bugx engine path --name bugx-quick.md`: lifetime, Supervisor, evidence, and reporting protocols.\n\nThese files are provided by the global engine; do not inspect the project's `.bugx/core`. If the project lacks `.bugx/manifest.json`, stop immediately and report this to the dispatcher. The dispatcher must first run the read-only command `bugx engine --root <ROOT> status --json`; only a result of `UNINITIALIZED` permits `bugx engine --root <ROOT> pre` to safely prepare a fresh project. If the result is `FATAL_BLOCKED`, another blocked state, or the status check fails, preserve project data and stop; never bypass the gate with `bugx init`, `bugx reset`, or `--force`. After the project layout is safely prepared, the dispatcher may refresh host Worker integration from the main session if needed. A Worker never runs host-control initialization or installation commands and never executes protocol steps while the layout is missing.\n\n## Worker role boundary (mandatory)\n\n- Handle only the coverage units or affinity task bundles the Supervisor assigns to you: `claim` (skip when the host has pre-reserved) → `worker-start` → mine and produce evidence → `checkpoint`; `life_delta` must be 0, and you never write lifetime, settle accounts, produce the final report, or take units outside the list.\n- Use only the worker channel: the Supervisor MCP's `bugx-supervisor-worker` tools (claim/worker_start/tool_call/heartbeat/checkpoint), or the same-named subcommands of `audit_supervisor.py` in the global engine; never call host-control tools (start/bootstrap/next_round/bind_context/finish/fail/recover) and never run the host-control entries' `pre|post|settle`.\n- Evidence may only be written into the `artifact_root` returned by the claim; out-of-bounds paths are rejected by the Supervisor. Unless the dispatcher explicitly provides an independent git worktree, never modify shared worktree source — fixes are performed serially by the host.\n- During long commands send a heartbeat every 5 minutes; on a non-zero return or `CONTROL_PAUSED`/`CONTROL_ABORTED`, stop at a safe boundary and report the state to the dispatcher.\n\n## ZCode Worker interaction adaptation (mandatory)\n\nA worker is a sub-agent: it presents no startup gate and must not call `AskUserQuestion` — a regular start is decided automatically by project configuration and raises no serial startup questionnaire. When a user decision is truly required, end directly and report the raw `BUGX_INTERACTION_REQUEST <json>` to the dispatcher; never answer on your own or guess options. Treat the worker itself as non-TTY: forward only the current single-choice request and continue once the dispatcher returns the answer.\n",
452
454
  "host.entry.body.claude_worker": "\n# BugX Worker — Claude Code concurrent worker sub-agent\n\nYou are BugX's concurrent worker sub-agent, dispatched in parallel within a Round by the main agent through Claude Code's subagent capability (`subagent_type=bugx-worker`). First read and obey the following global engine protocols via `bugx engine path --name <file>`; they are the only authoritative entities and this entry does not copy their content:\n\n- `bugx engine path --name bugx-worker.md`: worker unit-level execution rules (four start-up steps, mining discipline, case-filing oracle, hard evidence gate, checkpoint submission);\n- `bugx engine path --name bugx-runtime-contract.md` and `bugx engine path --name bugx-quick.md`: lifetime, Supervisor, evidence, and reporting protocols.\n\nThese files are provided by the global engine; do not inspect the project's `.bugx/core`. If the project lacks `.bugx/manifest.json`, stop immediately and report this to the dispatcher. The dispatcher must first run the read-only command `bugx engine --root <ROOT> status --json`; only a result of `UNINITIALIZED` permits `bugx engine --root <ROOT> pre` to safely prepare a fresh project. If the result is `FATAL_BLOCKED`, another blocked state, or the status check fails, preserve project data and stop; never bypass the gate with `bugx init`, `bugx reset`, or `--force`. After the project layout is safely prepared, the dispatcher may refresh host Worker integration from the main session if needed. A Worker never runs host-control initialization or installation commands and never executes protocol steps while the layout is missing.\n\n## Worker role boundary (mandatory)\n\n- Handle only the coverage units or affinity task bundles the Supervisor assigns to you: `claim` (skip when the host has pre-reserved) → `worker-start` → mine and produce evidence → `checkpoint`; `life_delta` must be 0, and you never write lifetime, settle accounts, produce the final report, or take units outside the list.\n- Use only the worker channel: the Supervisor MCP's `bugx-supervisor-worker` tools (claim/worker_start/tool_call/heartbeat/checkpoint), or the same-named subcommands of `audit_supervisor.py` in the global engine; never call host-control tools (start/bootstrap/next_round/bind_context/finish/fail/recover) and never run the host-control entries' `pre|post|settle`.\n- Evidence may only be written into the `artifact_root` returned by the claim; out-of-bounds paths are rejected by the Supervisor. Unless the dispatcher explicitly provides an independent git worktree, never modify shared worktree source — fixes are performed serially by the host.\n- During long commands send a heartbeat every 5 minutes; on a non-zero return or `CONTROL_PAUSED`/`CONTROL_ABORTED`, stop at a safe boundary and report the state to the dispatcher.\n\n## Claude Code Worker interaction adaptation (mandatory)\n\nA worker is a sub-agent: it presents no startup gate and must not call `AskUserQuestion` — a regular start is decided automatically by project configuration and raises no serial startup questionnaire. When a user decision is truly required, end directly and report the raw `BUGX_INTERACTION_REQUEST <json>` to the dispatcher; never answer on your own or guess options. Treat the worker itself as non-TTY: forward only the current single-choice request and continue once the dispatcher returns the answer.\n",
453
455
  "host.entry.body.cline_worker": "\n# BugX Worker — Cline concurrent worker sub-agent\n\nYou are BugX's concurrent worker sub-agent, dispatched serially by the main agent through a Cline interactive session, or in parallel within a Round by an independent Cline CLI process pool. First read and obey the following global engine protocols via `bugx engine path --name <file>`; they are the only authoritative entities and this entry does not copy their content:\n\n- `bugx engine path --name bugx-worker.md`: worker unit-level execution rules (four start-up steps, mining discipline, case-filing oracle, hard evidence gate, checkpoint submission);\n- `bugx engine path --name bugx-runtime-contract.md` and `bugx engine path --name bugx-quick.md`: lifetime, Supervisor, evidence, and reporting protocols.\n\nThese files are provided by the global engine; do not inspect the project's `.bugx/core`. If the project lacks `.bugx/manifest.json`, stop immediately and report this to the dispatcher. The dispatcher must first run the read-only command `bugx engine --root <ROOT> status --json`; only a result of `UNINITIALIZED` permits `bugx engine --root <ROOT> pre` to safely prepare a fresh project. If the result is `FATAL_BLOCKED`, another blocked state, or the status check fails, preserve project data and stop; never bypass the gate with `bugx init`, `bugx reset`, or `--force`. After the project layout is safely prepared, the dispatcher may refresh host Worker integration from the main session if needed. A Worker never runs host-control initialization or installation commands and never executes protocol steps while the layout is missing.\n\n## Worker role boundary (mandatory)\n\n- Handle only the coverage units or affinity task bundles the Supervisor assigns to you: `claim` (skip when the host has pre-reserved) → `worker-start` → mine and produce evidence → `checkpoint`; `life_delta` must be 0, and you never write lifetime, settle accounts, produce the final report, or take units outside the list.\n- Use only the worker channel: the Supervisor MCP's `bugx-supervisor-worker` tools (claim/worker_start/tool_call/heartbeat/checkpoint), or the same-named subcommands of `audit_supervisor.py` in the global engine; never call host-control tools (start/bootstrap/next_round/bind_context/finish/fail/recover) and never run the host-control entries' `pre|post|settle`.\n- Evidence may only be written into the `artifact_root` returned by the claim; out-of-bounds paths are rejected by the Supervisor. Unless the dispatcher explicitly provides an independent git worktree, never modify shared worktree source — fixes are performed serially by the host.\n- In Cline process-pool mode the claim's data directory is locked to `<artifact_root>/.cline_data`, with `CLINE_DATA_DIR` and `--data-dir` injected; that directory's MCP may only contain `bugx-supervisor-worker` (`--role worker`) and `bugx-docs`, and must never start the controlling `bugx-supervisor`.\n- During long commands send a heartbeat every 5 minutes; on a non-zero return or `CONTROL_PAUSED`/`CONTROL_ABORTED`, stop at a safe boundary and report the state to the dispatcher.\n\n## Cline Worker interaction adaptation (mandatory)\n\nA worker is a sub-agent: it presents no startup gate and must not call `ask_question` — a regular start is decided automatically by project configuration and raises no serial startup questionnaire. When a user decision is truly required, end directly and report the raw `BUGX_INTERACTION_REQUEST <json>` to the dispatcher; never answer on your own or guess options. Treat the worker itself as non-TTY: forward only the current single-choice request and continue once the dispatcher returns the answer.\n",
@@ -434,6 +434,7 @@
434
434
  "host.entry.section.workbuddy": "\n\n## WorkBuddy AI 适配(强制)\n\n本入口以 WorkBuddy Skill 载入,不执行 `bugx install`,不自行猜测门禁答案,也不把普通文本当作已完成的用户选择。WorkBuddy 的桌面端通过 Skill/插件管理启用;代码开发模式从项目 `.workbuddy/` 或兼容的 `.codebuddy/` 配置读取本入口。\n",
435
435
  "host.entry.section.qoder": "\n\n## Qoder 原生交互适配(强制)\n\n启动器必须显式使用 `--host qoder` 写入当前 runtime,不得用项目配置推断宿主。使用当前 Qoder 会话提供的 `ask_question`(或等价结构化用户选择控件);按选项的唯一 `value` 及受控 `action` 执行,禁止从 label 猜动作。\n",
436
436
  "host.entry.section.trea": "\n\n## Trea 原生交互适配(强制)\n\n使用 Trea 的 `AskUserQuestion` 工具呈现交互决策,每次只提交一个问题;按当前问题选项的唯一 `value` 及受控 `action` 执行,禁止从中文 label 猜动作。\n",
437
+ "host.entry.section.copilot": "\n\n## GitHub Copilot 原生交互适配(强制)\n\n本入口适配 GitHub Copilot Agent 模式与 Copilot Chat 指令规范。通过项目级 `.github/agents/bugx.agent.md` 和 `.github/copilot-instructions.md` 自动加载;在需要人机交互单选决策时,使用 Copilot 原生结构化控件呈现,按选项的唯一 `value` 及受控 `action` 执行。MCP 配置由安装器写入 `.vscode/mcp.json` 与 `.mcp.json`,必须启用 `bugx-supervisor` 与 worker。\n",
437
438
  "host.entry.section.chatgpt.basic": "\n\n## ChatGPT 原生交互适配(强制)\n\n使用 ChatGPT 宿主提供的结构化选择控件呈现交互决策,按选项唯一 `value` 及受控 `action` 执行。\n",
438
439
  "host.entry.section.qoder.basic": "",
439
440
  "host.entry.header.opencode": "# BugX\n\n这是 BugX 的 OpenCode 原生入口。先读取全局引擎协议:通过 `bugx engine path --name bugx-runtime-contract.md` 和 `bugx engine path --name bugx-quick.md` 读取全局协议,并遵守其中的寿命、Supervisor、证据和报告协议。\n\n该入口只把任务交给当前 OpenCode;CLI 只安装资源,不执行审计。公开 Agent 模板来源:`{source}`。\n",
@@ -448,6 +449,7 @@
448
449
  "host.entry.header.qoder": "# BugX\n\n这是 BugX 的 Qoder AI 入口。先读取全局引擎协议:通过 `bugx engine path --name bugx-runtime-contract.md` 和 `bugx engine path --name bugx-quick.md` 读取全局协议,并遵守其中的寿命、Supervisor、证据和报告协议。\n\n该入口只把任务交给当前 Qoder AI;CLI 只安装资源,不执行审计。公开 Agent 模板来源:`{source}`。\n",
449
450
  "host.entry.header.trea": "# BugX\n\n这是 BugX 的 Trea 入口。先读取全局引擎协议:通过 `bugx engine path --name bugx-runtime-contract.md` 和 `bugx engine path --name bugx-quick.md` 读取全局协议,并遵守其中的寿命、Supervisor、证据和报告协议。\n\n该入口只把任务交给当前 Trea;CLI 只安装资源,不执行审计。公开 Agent 模板来源:`{source}`。\n",
450
451
  "host.entry.header.funide": "# BugX\n\n这是 BugX 的 FunIDE 入口。先读取全局引擎协议:通过 `bugx engine path --name bugx-runtime-contract.md` 和 `bugx engine path --name bugx-quick.md` 读取全局协议,并遵守其中的寿命、Supervisor、证据和报告协议。\n\n该入口只把任务交给当前 FunIDE;CLI 只安装资源,不执行审计。公开 Agent 模板来源:`{source}`。\n",
452
+ "host.entry.header.copilot": "# BugX\n\n这是 BugX 的 GitHub Copilot 原生入口。先读取全局引擎协议:通过 `bugx engine path --name bugx-runtime-contract.md` 和 `bugx engine path --name bugx-quick.md` 读取全局协议,并遵守其中的寿命、Supervisor、证据和报告协议。\n\n该入口只把任务交给当前 GitHub Copilot;CLI 只安装资源,不执行审计。公开 Agent 模板来源:`{source}`。\n",
451
453
  "host.entry.body.zcode_worker": "\n# BugX Worker — ZCode 并发 Worker 子智能体\n\n你是 BugX 的并发 worker 子智能体,由主 Agent 通过 ZCode 的 subagent 能力(`subagent_type=bugx-worker`;插件形态为 `bugx:bugx-worker`)在 Round 内并发派发。先通过 `bugx engine path --name <文件>` 读取并遵守以下全局引擎协议;它们是唯一权威实体,本入口不复制其内容:\n\n- `bugx engine path --name bugx-worker.md`:worker 单元级执行规则(开工四步、挖掘纪律、立案 oracle、证据硬门槛、checkpoint 提交);\n- `bugx engine path --name bugx-runtime-contract.md` 与 `bugx engine path --name bugx-quick.md`:寿命、Supervisor、证据和报告协议。\n\n上述文件由全局引擎提供,不检查项目 `.bugx/core`。若项目缺少 `.bugx/manifest.json`,立即停止并将事实报告给派发方。派发方必须先运行只读命令 `bugx engine --root <ROOT> status --json`:只有结果为 `UNINITIALIZED` 时才运行 `bugx engine --root <ROOT> pre` 安全准备新项目;若为 `FATAL_BLOCKED`、其他阻断状态或检查失败,保留项目数据并停止,不得用 `bugx init`、`bugx reset` 或 `--force` 绕过。项目布局准备完成后,如需刷新宿主 Worker 集成,由派发方在主会话中执行;Worker 不运行主控初始化或安装命令,也不在布局缺失时执行协议步骤。\n\n## Worker 角色边界(强制)\n\n- 只负责 Supervisor 分配给你的覆盖单元或亲和任务包:`claim`(宿主已预占时跳过)→ `worker-start` → 挖掘举证 → `checkpoint`;`life_delta` 必须为 0,不写寿命、不结算、不生成最终报告、不领取清单外的单元。\n- 只能使用 worker 通道:Supervisor MCP 的 `bugx-supervisor-worker` 工具(claim/worker_start/tool_call/heartbeat/checkpoint),或全局引擎中的 `audit_supervisor.py` 的同名子命令;不得调用宿主控制工具(start/bootstrap/next_round/bind_context/finish/fail/recover),不得执行宿主控制入口的 `pre|post|settle`。\n- 证据只能写入 claim 返回的 `artifact_root`,越界路径会被 Supervisor 拒绝;没有派发方明确提供独立 git worktree 时,不得修改共享工作树源码,修复由宿主串行完成。\n- 长命令期间每 5 分钟补一次 heartbeat;返回非零或 `CONTROL_PAUSED`/`CONTROL_ABORTED` 时,停在安全边界并把状态报告给派发方。\n\n## ZCode Worker 交互适配(强制)\n\nWorker 是子智能体,不呈现任何启动门禁,也不得调用 `AskUserQuestion`——常规启动由项目配置自动决策,不发起串行启动问卷。确需用户决策时,直接结束并把 `BUGX_INTERACTION_REQUEST <json>` 原文报告给派发方,不得自行作答或猜选项。Worker 自身按非 TTY 处理:只转发当前一个单选请求,答案由派发方回传后再继续。\n",
452
454
  "host.entry.body.claude_worker": "\n# BugX Worker — Claude Code 并发 Worker 子智能体\n\n你是 BugX 的并发 worker 子智能体,由主 Agent 通过 Claude Code 的 subagent 能力(`subagent_type=bugx-worker`)在 Round 内并发派发。先通过 `bugx engine path --name <文件>` 读取并遵守以下全局引擎协议;它们是唯一权威实体,本入口不复制其内容:\n\n- `bugx engine path --name bugx-worker.md`:worker 单元级执行规则(开工四步、挖掘纪律、立案 oracle、证据硬门槛、checkpoint 提交);\n- `bugx engine path --name bugx-runtime-contract.md` 与 `bugx engine path --name bugx-quick.md`:寿命、Supervisor、证据和报告协议。\n\n上述文件由全局引擎提供,不检查项目 `.bugx/core`。若项目缺少 `.bugx/manifest.json`,立即停止并将事实报告给派发方。派发方必须先运行只读命令 `bugx engine --root <ROOT> status --json`:只有结果为 `UNINITIALIZED` 时才运行 `bugx engine --root <ROOT> pre` 安全准备新项目;若为 `FATAL_BLOCKED`、其他阻断状态或检查失败,保留项目数据并停止,不得用 `bugx init`、`bugx reset` 或 `--force` 绕过。项目布局准备完成后,如需刷新宿主 Worker 集成,由派发方在主会话中执行;Worker 不运行主控初始化或安装命令,也不在布局缺失时执行协议步骤。\n\n## Worker 角色边界(强制)\n\n- 只负责 Supervisor 分配给你的覆盖单元或亲和任务包:`claim`(宿主已预占时跳过)→ `worker-start` → 挖掘举证 → `checkpoint`;`life_delta` 必须为 0,不写寿命、不结算、不生成最终报告、不领取清单外的单元。\n- 只能使用 worker 通道:Supervisor MCP 的 `bugx-supervisor-worker` 工具(claim/worker_start/tool_call/heartbeat/checkpoint),或全局引擎中的 `audit_supervisor.py` 的同名子命令;不得调用宿主控制工具(start/bootstrap/next_round/bind_context/finish/fail/recover),不得执行宿主控制入口的 `pre|post|settle`。\n- 证据只能写入 claim 返回的 `artifact_root`,越界路径会被 Supervisor 拒绝;没有派发方明确提供独立 git worktree 时,不得修改共享工作树源码,修复由宿主串行完成。\n- 长命令期间每 5 分钟补一次 heartbeat;返回非零或 `CONTROL_PAUSED`/`CONTROL_ABORTED` 时,停在安全边界并把状态报告给派发方。\n\n## Claude Code Worker 交互适配(强制)\n\nWorker 是子智能体,不呈现任何启动门禁,也不得调用 `AskUserQuestion`——常规启动由项目配置自动决策,不发起串行启动问卷。确需用户决策时,直接结束并把 `BUGX_INTERACTION_REQUEST <json>` 原文报告给派发方,不得自行作答或猜选项。Worker 自身按非 TTY 处理:只转发当前一个单选请求,答案由派发方回传后再继续。\n",
453
455
  "host.entry.body.cline_worker": "\n# BugX Worker — Cline 并发 Worker 子智能体\n\n你是 BugX 的并发 worker 子智能体,由主 Agent 通过 Cline 交互会话串行派发,或由独立 Cline CLI 进程池在 Round 内并发派发。先通过 `bugx engine path --name <文件>` 读取并遵守以下全局引擎协议;它们是唯一权威实体,本入口不复制其内容:\n\n- `bugx engine path --name bugx-worker.md`:worker 单元级执行规则(开工四步、挖掘纪律、立案 oracle、证据硬门槛、checkpoint 提交);\n- `bugx engine path --name bugx-runtime-contract.md` 与 `bugx engine path --name bugx-quick.md`:寿命、Supervisor、证据和报告协议。\n\n上述文件由全局引擎提供,不检查项目 `.bugx/core`。若项目缺少 `.bugx/manifest.json`,立即停止并将事实报告给派发方。派发方必须先运行只读命令 `bugx engine --root <ROOT> status --json`:只有结果为 `UNINITIALIZED` 时才运行 `bugx engine --root <ROOT> pre` 安全准备新项目;若为 `FATAL_BLOCKED`、其他阻断状态或检查失败,保留项目数据并停止,不得用 `bugx init`、`bugx reset` 或 `--force` 绕过。项目布局准备完成后,如需刷新宿主 Worker 集成,由派发方在主会话中执行;Worker 不运行主控初始化或安装命令,也不在布局缺失时执行协议步骤。\n\n## Worker 角色边界(强制)\n\n- 只负责 Supervisor 分配给你的覆盖单元或亲和任务包:`claim`(宿主已预占时跳过)→ `worker-start` → 挖掘举证 → `checkpoint`;`life_delta` 必须为 0,不写寿命、不结算、不生成最终报告、不领取清单外的单元。\n- 只能使用 worker 通道:Supervisor MCP 的 `bugx-supervisor-worker` 工具(claim/worker_start/tool_call/heartbeat/checkpoint),或全局引擎中的 `audit_supervisor.py` 的同名子命令;不得调用宿主控制工具(start/bootstrap/next_round/bind_context/finish/fail/recover),不得执行宿主控制入口的 `pre|post|settle`。\n- 证据只能写入 claim 返回的 `artifact_root`,越界路径会被 Supervisor 拒绝;没有派发方明确提供独立 git worktree 时,不得修改共享工作树源码,修复由宿主串行完成。\n- Cline 进程池模式会把本 claim 的数据目录锁定为 `<artifact_root>/.cline_data`,同时注入 `CLINE_DATA_DIR` 与 `--data-dir`;该目录的 MCP 只能包含 `bugx-supervisor-worker`(`--role worker`)和 `bugx-docs`,不得启动主控 `bugx-supervisor`。\n- 长命令期间每 5 分钟补一次 heartbeat;返回非零或 `CONTROL_PAUSED`/`CONTROL_ABORTED` 时,停在安全边界并把状态报告给派发方。\n\n## Cline Worker 交互适配(强制)\n\nWorker 是子智能体,不呈现任何启动门禁,也不得调用 `ask_question`——常规启动由项目配置自动决策,不发起串行启动问卷。确需用户决策时,直接结束并把 `BUGX_INTERACTION_REQUEST <json>` 原文报告给派发方,不得自行作答或猜选项。Worker 自身按非 TTY 处理:只转发当前一个单选请求,答案由派发方回传后再继续。\n",
@@ -1101,6 +1101,36 @@ def handle_supervisor_bind_context(service: Any, arguments: Mapping[str, object]
1101
1101
  ))
1102
1102
 
1103
1103
 
1104
+ def _maybe_auto_record_finish_telemetry(result: Mapping[str, object]) -> None:
1105
+ """DOC-126: 在 Supervisor finish 完成时静默为脱敏飞轮入队 code_review 摘要。"""
1106
+ try:
1107
+ from core.cloud_sync.flywheel_client import record_review_telemetry
1108
+
1109
+ findings = result.get("findings")
1110
+ findings_count = len(findings) if isinstance(findings, list) else int(result.get("findings_count", 0))
1111
+ coverage_summary = result.get("coverage_summary") if isinstance(result.get("coverage_summary"), Mapping) else {}
1112
+ total_units = int(coverage_summary.get("total", 0))
1113
+
1114
+ summary = {
1115
+ "findings_count": findings_count,
1116
+ "total_units": total_units,
1117
+ "status": str(result.get("status") or "completed"),
1118
+ "round_no": result.get("round_no"),
1119
+ }
1120
+ metrics = {
1121
+ "findings_count": findings_count,
1122
+ "total_units": total_units,
1123
+ }
1124
+ record_review_telemetry(
1125
+ review_summary=summary,
1126
+ metrics=metrics,
1127
+ event_type="code_review",
1128
+ flush=True,
1129
+ )
1130
+ except Exception:
1131
+ pass
1132
+
1133
+
1104
1134
  def handle_supervisor_finish(service: Any, arguments: Mapping[str, object]) -> dict[str, object]:
1105
1135
  name = "bugx_supervisor_finish"
1106
1136
  service._require_role(arguments, name, "host")
@@ -1109,10 +1139,12 @@ def handle_supervisor_finish(service: Any, arguments: Mapping[str, object]) -> d
1109
1139
  compact = bool(arguments.get("compact", False))
1110
1140
  if coverage_complete is not None and not isinstance(coverage_complete, bool):
1111
1141
  raise McpProtocolError("coverage_complete 必须是布尔值或 null")
1112
- return project_state(supervisor.finish(
1142
+ res = project_state(supervisor.finish(
1113
1143
  coverage_complete=coverage_complete,
1114
1144
  expected_revision=arguments.get("expected_revision"),
1115
1145
  ), compact=compact)
1146
+ _maybe_auto_record_finish_telemetry(res)
1147
+ return res
1116
1148
 
1117
1149
 
1118
1150
  def handle_supervisor_fail(service: Any, arguments: Mapping[str, object]) -> dict[str, object]:
@@ -1259,7 +1291,7 @@ def handle_supervisor_run_sandboxed_probe(service: Any, arguments: Mapping[str,
1259
1291
  except Exception:
1260
1292
  pass
1261
1293
  stdout, stderr = proc.communicate()
1262
- exit_code = -signal.SIGKILL
1294
+ exit_code = -getattr(signal, "SIGKILL", 9)
1263
1295
  stderr = (stderr or "") + f"\n[timeout]: Command timed out after {timeout}s and process group was terminated."
1264
1296
  except Exception as exc:
1265
1297
  exit_code = 1
@@ -209,10 +209,41 @@ def handle_global_telemetry(service: Any, arguments: Mapping[str, object]) -> di
209
209
  }
210
210
 
211
211
 
212
+ def handle_record_telemetry(service: Any, arguments: Mapping[str, object]) -> dict[str, object]:
213
+ """MCP 接口:上报轻量代码审查或探测遥测事实并可选即时推送。"""
214
+ del service
215
+ summary = arguments.get("summary")
216
+ if not isinstance(summary, Mapping):
217
+ return {"status": "error", "error": "summary 必须是非空对象"}
218
+
219
+ event_type = str(arguments.get("event_type") or "code_review").strip()
220
+ quality = arguments.get("quality", "tier-2")
221
+ metrics = arguments.get("metrics")
222
+ flush_now = bool(arguments.get("flush_now", True))
223
+
224
+ try:
225
+ from core.cloud_sync.flywheel_client import FlywheelUploader
226
+
227
+ with FlywheelUploader() as uploader:
228
+ if not uploader.data_sharing:
229
+ return {"status": "disabled", "message": "遥测共享未开启"}
230
+ res = uploader.record_and_flush(
231
+ review_summary=summary,
232
+ quality=quality,
233
+ metrics=metrics if isinstance(metrics, Mapping) else None,
234
+ event_type=event_type,
235
+ flush=flush_now,
236
+ )
237
+ return {"status": "ok", "telemetry": res}
238
+ except Exception as exc:
239
+ return {"status": "error", "error": str(exc)}
240
+
241
+
212
242
  TELEMETRY_HANDLERS: dict[str, Any] = {
213
243
  "bugx_scheduling_telemetry": handle_scheduling_telemetry,
214
244
  "bugx_global_telemetry": handle_global_telemetry,
215
245
  "bugx_retrieval_metrics": handle_retrieval_metrics,
246
+ "bugx_record_telemetry": handle_record_telemetry,
216
247
  }
217
248
 
218
249
 
@@ -220,6 +251,7 @@ __all__ = [
220
251
  "TELEMETRY_HANDLERS",
221
252
  "clear_retrieval_metrics",
222
253
  "handle_global_telemetry",
254
+ "handle_record_telemetry",
223
255
  "handle_retrieval_metrics",
224
256
  "handle_scheduling_telemetry",
225
257
  "record_retrieval_metric",
@@ -657,6 +657,40 @@ def _build_tool_table() -> tuple[tuple[frozenset[str], dict[str, object]], ...]:
657
657
  },
658
658
  },
659
659
  }),
660
+ (_SHARED_ROLES, {
661
+ "name": "bugx_record_telemetry",
662
+ "description": "向脱敏飞轮队列上报轻量代码审查或探测遥测事实(文件数、缺陷分级统计、耗时等脱敏指标),支持即时或排队外发。",
663
+ "inputSchema": {
664
+ "type": "object",
665
+ "properties": {
666
+ "event_type": {
667
+ "type": "string",
668
+ "description": "遥测事件类型,如 code_review、recon_probe(默认 code_review)",
669
+ "default": "code_review",
670
+ },
671
+ "summary": {
672
+ "type": "object",
673
+ "description": "脱敏审查/探测统计指标(禁止传递任何源码明文、路径凭据)",
674
+ },
675
+ "metrics": {
676
+ "type": "object",
677
+ "description": "性能与耗时度量(如 duration_ms、findings_count 等)",
678
+ },
679
+ "quality": {
680
+ "type": "string",
681
+ "enum": ["tier-1", "tier-2", "tier-3"],
682
+ "default": "tier-2",
683
+ "description": "数据质量评级",
684
+ },
685
+ "flush_now": {
686
+ "type": "boolean",
687
+ "description": "是否在入队后立即尝试网络静默推送(默认 true)",
688
+ "default": True,
689
+ },
690
+ },
691
+ "required": ["summary"],
692
+ },
693
+ }),
660
694
  (_WORKER_ONLY, {
661
695
  "name": "bugx_fuzz_concurrency",
662
696
  "description": "并发竞态与时序死锁专项扰动工具:注入微秒级上下文切换抖动并检测数据竞态或死锁。",
@@ -317,6 +317,12 @@ def _check_venv_shebang(
317
317
  first_line = handle.readline(4096)
318
318
  except OSError as exc:
319
319
  return f"入口无法读取: {entry_rel}({exc})"
320
+ if (
321
+ first_line.startswith(b"MZ")
322
+ or entry_path.suffix.lower() in (".exe", ".com", ".cmd", ".bat")
323
+ ):
324
+ # Windows PE 可执行二进制文件或脚本(由 Windows 原生加载执行,无 Unix 文本 shebang)
325
+ return None
320
326
  if not first_line.startswith(b"#!"):
321
327
  return f"入口缺少 shebang(pypi console script 必须有): {entry_rel}"
322
328
  interpreter = first_line[2:].strip().decode("utf-8", "replace")