bugx-cli 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/README.md +5 -3
- package/core/agent/agent_execution.py +7 -0
- package/core/assets/bugx-wechat-group.png +0 -0
- package/core/bugx.md +2 -2
- package/core/bugx_paths.py +10 -2
- package/core/bundled_docs/OVERVIEW.md +311 -0
- package/core/bundled_docs/README.md +10 -0
- package/core/bundled_docs/README_EN.md +278 -0
- package/core/bundled_docs/ai/01_AI_REFERENCE.md +838 -0
- package/core/bundled_docs/ai/02_AI_USAGE.md +161 -0
- package/core/bundled_docs/ai/03_AI_COMMANDS.md +322 -0
- package/core/bundled_docs/guides/01_USER_GUIDE.md +887 -0
- package/core/bundled_docs/guides/02_COMMANDS.md +935 -0
- package/core/bundled_docs/guides/03_TROUBLESHOOTING.md +763 -0
- package/core/bundled_docs/guides/04_CLOUD_AUTH_AND_SYNC_COOKBOOK.md +48 -0
- package/core/bundled_docs/guides/05_HOST_MATRIX_AND_DISPATCH.md +25 -0
- package/core/bundled_docs/guides/06_PROBES_AND_POC_COOKBOOK.md +49 -0
- package/core/bundled_docs/guides/07_LIFECYCLE_AND_RECOVERY_STATES.md +46 -0
- package/core/bundled_docs/guides/08_LESSONS_AND_PRIVACY_BOUNDARY.md +35 -0
- package/core/bundled_docs/hosts/bugx-claude_SKILL.md +326 -0
- package/core/bundled_docs/hosts/bugx-dsh_SKILL.md +229 -0
- package/core/bundled_docs/hosts/bugx-opencode_SKILL.md +129 -0
- package/core/bundled_docs/hosts/bugx-zcode_SKILL.md +459 -0
- package/core/bundled_docs/hosts/bugx_SKILL.md +118 -0
- package/core/bundled_docs/hosts/cline_bugx_SKILL.md +69 -0
- package/core/bundled_docs/hosts/platform_bugx_SKILL.md +50 -0
- package/core/bundled_docs/manifest.json +140 -0
- package/core/bundled_docs/reference/01_ENVIRONMENT_VARIABLES.md +422 -0
- package/core/bundled_docs/reference/04_REPOSITORY_TOPOLOGY.md +180 -0
- package/core/cli-help.txt +7 -3
- package/core/cloud_sync/cloud_client.py +81 -2
- package/core/cloud_sync/endpoint_router.py +22 -9
- package/core/cloud_sync/issue_uploader.py +297 -0
- package/core/cloud_sync/sensitive_filter.py +77 -7
- package/core/contracts/AGENT_GUIDE.md +3 -9
- package/core/contracts/README.md +1 -1
- package/core/contracts/bugx-runtime-contract.md +10 -20
- package/core/contracts/bugx-worker.md +1 -1
- package/core/coverage/coverage_ai_review.py +15 -11
- package/core/coverage/coverage_bootstrap.py +18 -13
- package/core/coverage/coverage_discovery.py +1 -1
- package/core/dev_harness/interaction_preset.py +1 -1
- package/core/engine-integrity.json +283 -159
- package/core/host_acp/README.md +4 -0
- package/core/host_acp/agnescode.py +128 -0
- package/core/host_acp/antigravity.py +153 -0
- package/core/host_runtime/README.md +3 -0
- package/core/host_runtime/adapters.py +5 -1
- package/core/host_runtime/antigravity.py +162 -0
- package/core/host_runtime/host_bootstrap.py +18 -7
- package/core/host_runtime/host_evaluators.py +4 -4
- package/core/host_runtime/host_registry.py +3 -1
- package/core/host_runtime/mcp_process_tracker.py +30 -3
- package/core/host_runtime/mcp_registry_gate.py +34 -11
- package/core/hosts/README.md +4 -0
- package/core/hosts/agnescode.py +415 -0
- package/core/hosts/antigravity.py +115 -0
- package/core/hosts/codex.py +3 -0
- package/core/hosts/dsh.py +42 -23
- package/core/hosts/minimax.py +5 -4
- package/core/hosts/opencode.py +11 -3
- package/core/i18n.py +94 -5
- package/core/infra/README.md +1 -1
- package/core/infra/build_info.py +2 -2
- package/core/infra/python_runtime.py +4 -1
- package/core/launch_phases/README.md +2 -2
- package/core/launch_phases/finding_confirm_phase.py +1 -1
- package/core/launch_phases/semantic_recon.py +3 -19
- package/core/launch_phases/startup_version_gate.py +2 -2
- package/core/launch_phases/supervisor_bridge.py +2 -0
- package/core/launch_phases/supervisor_degraded.py +7 -5
- package/core/launch_phases/verify_loop.py +3 -19
- package/core/ledger/README.md +1 -1
- package/core/ledger/finding_confirmation.py +1 -1
- package/core/ledger/finding_verification.py +2 -20
- package/core/ledger/fp_ledger.py +3 -19
- package/core/ledger/life_ledger.py +7 -33
- package/core/ledger/schema.py +1 -1
- package/core/locales/en-US.json +3 -3
- package/core/locales/zh-CN.json +3 -3
- package/core/mcp_handlers/supervisor_handlers.py +1 -1
- package/core/mcp_runtime_support/common.py +6 -0
- package/core/mcp_runtime_support/environment.py +88 -24
- package/core/metadata.txt +1 -1
- package/core/planning/README.md +1 -1
- package/core/planning/prompt_harness.py +2 -2
- package/core/planning/target_sandbox_manager.py +2 -0
- package/core/probes/codebase_memory_probe.py +43 -24
- package/core/probes/mobile_probe.py +1 -0
- package/core/probes/probe_registry.py +10 -7
- package/core/probes/sast_probe.py +1 -1
- package/core/probes/sca_scanner.py +1 -1
- package/core/project_profiler/constants.py +1 -1
- package/core/prompts/command_routing_en.md +6 -5
- package/core/prompts/command_routing_zh.md +6 -5
- package/core/repair/rsi_rounds.py +3 -0
- package/core/repair/self_heal.py +160 -6
- package/core/retrieval/README.md +1 -1
- package/core/retrieval/symbol_index.py +227 -52
- package/core/runtime/README.md +1 -1
- package/core/runtime/daemon_runner.py +3 -2
- package/core/runtime/project_init.py +1 -1
- package/core/runtime/scenario_eval.py +5 -1
- package/core/runtime/tool_install_targets.py +12 -2
- package/core/skills/README.md +4 -2
- package/core/skills/bugx_docs_cloud_sync.py +658 -0
- package/core/skills/bugx_docs_mcp_server.py +966 -140
- package/core/skills/bugx_mcp_server.py +9 -0
- package/core/skills/mcp_session_proof.py +3 -31
- package/core/supervisor/README.md +1 -1
- package/core/supervisor/finding_commit.py +3 -24
- package/core/supervisor/task_scheduler.py +5 -2
- package/core/supervisor/worker_execution.py +16 -3
- package/core/supervisor/worker_handoff.py +2 -2
- package/core/webui/docs_session_service.py +40 -2
- package/core/webui/mcp_inspector.py +6 -6
- package/ecosystem/integrations/cline/skills/bugx/SKILL.md +46 -46
- package/ecosystem/integrations/dsh/agents/bugx.md +2 -1
- package/ecosystem/integrations/dsh/mcp/package.json +1 -1
- package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +5 -5
- package/ecosystem/integrations/dsh/ui/package.json +1 -1
- package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +4 -4
- package/ecosystem/integrations/opencode/mcp-lock.json +1 -1
- package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
- package/ecosystem/integrations/pi/skills/bugx/SKILL.md +5 -5
- package/ecosystem/integrations/qoder/CONNECTORS.md +11 -23
- package/ecosystem/integrations/qoder/connector-meta.json +1 -1
- package/ecosystem/integrations/workbuddy/connector-meta.json +1 -1
- package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +8 -7
- package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +1 -1
- package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +1 -1
- package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +1 -1
- package/ecosystem/plugins/bugx/agents/bugx-worker.md +14 -18
- package/ecosystem/plugins/bugx/agents/bugx.md +45 -49
- package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +7 -7
- package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +2 -2
- package/interfaces/cli/bugx_cli/__init__.py +1 -1
- package/interfaces/cli/bugx_cli/cli.py +153 -8
- package/interfaces/cli/bugx_cli/commands/agent.py +376 -69
- package/interfaces/cli/bugx_cli/commands/audit.py +2 -1
- package/interfaces/cli/bugx_cli/commands/cloud.py +42 -1
- package/interfaces/cli/bugx_cli/commands/doctor.py +650 -223
- package/interfaces/cli/bugx_cli/commands/guide.py +143 -0
- package/interfaces/cli/bugx_cli/commands/issue.py +262 -0
- package/interfaces/cli/bugx_cli/commands/lifecycle.py +56 -26
- package/interfaces/cli/bugx_cli/commands/patch.py +5 -1
- package/interfaces/cli/bugx_cli/commands/plugin.py +306 -56
- package/interfaces/cli/bugx_cli/commands/plugin_antigravity.py +350 -0
- package/interfaces/cli/bugx_cli/commands/plugin_claude.py +2 -2
- package/interfaces/cli/bugx_cli/commands/plugin_kimi.py +154 -62
- package/interfaces/cli/bugx_cli/commands/plugin_minimax.py +308 -108
- package/interfaces/cli/bugx_cli/commands/system.py +11 -1
- package/interfaces/cli/bugx_cli/common.py +39 -8
- package/interfaces/cli/bugx_cli/host_adapters.py +46 -3
- package/interfaces/cli/bugx_cli/hosts/registry.py +3 -2
- package/interfaces/cli/bugx_cli/hosts/template_engine.py +21 -2
- package/interfaces/cli/bugx_cli/infra/__init__.py +4 -0
- package/interfaces/cli/bugx_cli/infra/ai_advisor.py +14 -12
- package/interfaces/cli/bugx_cli/infra/engine_installer.py +76 -10
- package/interfaces/cli/bugx_cli/infra/host_sync.py +66 -1
- package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +240 -50
- package/package.json +3 -2
- package/pyproject.toml +22 -2
- package/scripts/sync-version.mjs +1 -1
- package/skills/README.md +1 -2
- package/skills/platform/bugx/SKILL.md +50 -0
- package/skills/platform/bugx-user/SKILL.md +0 -92
|
@@ -41,6 +41,15 @@ from typing import Any, Callable, Mapping, Sequence
|
|
|
41
41
|
from core.infra.build_info import BASE_VERSION
|
|
42
42
|
from urllib.parse import parse_qs, urlparse
|
|
43
43
|
|
|
44
|
+
os.environ.setdefault("PYTHONUTF8", "1")
|
|
45
|
+
for _stream, _err_mode in ((sys.stdin, "strict"), (sys.stdout, "replace"), (sys.stderr, "replace")):
|
|
46
|
+
_reconf = getattr(_stream, "reconfigure", None)
|
|
47
|
+
if callable(_reconf):
|
|
48
|
+
try:
|
|
49
|
+
_reconf(encoding="utf-8", errors=_err_mode)
|
|
50
|
+
except (OSError, ValueError):
|
|
51
|
+
pass
|
|
52
|
+
|
|
44
53
|
try:
|
|
45
54
|
import fcntl
|
|
46
55
|
except ImportError: # pragma: no cover - Windows hosts use msvcrt or fallback.
|
|
@@ -26,6 +26,8 @@ from contextlib import contextmanager
|
|
|
26
26
|
from pathlib import Path
|
|
27
27
|
from typing import Any, Mapping
|
|
28
28
|
|
|
29
|
+
import core.secure_atomic as secure_atomic
|
|
30
|
+
|
|
29
31
|
|
|
30
32
|
SCHEMA_VERSION = 2
|
|
31
33
|
MAX_PROOF_BYTES = 64 * 1024
|
|
@@ -286,37 +288,7 @@ def retire_request_path(state_root: Path, instance: str) -> Path:
|
|
|
286
288
|
def _atomic_bytes(path: Path, payload: bytes, *, mode: int = 0o600) -> None:
|
|
287
289
|
if len(payload) > MAX_PROOF_BYTES:
|
|
288
290
|
raise SessionProofError(f"proof 超过 {MAX_PROOF_BYTES} bytes")
|
|
289
|
-
|
|
290
|
-
try:
|
|
291
|
-
os.chmod(path.parent, 0o700)
|
|
292
|
-
except OSError:
|
|
293
|
-
pass
|
|
294
|
-
fd, temporary = tempfile.mkstemp(prefix=f".{path.name}.", dir=str(path.parent))
|
|
295
|
-
try:
|
|
296
|
-
os.fchmod(fd, mode)
|
|
297
|
-
with os.fdopen(fd, "wb") as handle:
|
|
298
|
-
handle.write(payload)
|
|
299
|
-
handle.flush()
|
|
300
|
-
os.fsync(handle.fileno())
|
|
301
|
-
os.replace(temporary, path)
|
|
302
|
-
try:
|
|
303
|
-
descriptor = os.open(path.parent, os.O_RDONLY)
|
|
304
|
-
try:
|
|
305
|
-
os.fsync(descriptor)
|
|
306
|
-
finally:
|
|
307
|
-
os.close(descriptor)
|
|
308
|
-
except OSError:
|
|
309
|
-
pass
|
|
310
|
-
except BaseException:
|
|
311
|
-
try:
|
|
312
|
-
os.close(fd)
|
|
313
|
-
except OSError:
|
|
314
|
-
pass
|
|
315
|
-
try:
|
|
316
|
-
os.unlink(temporary)
|
|
317
|
-
except OSError:
|
|
318
|
-
pass
|
|
319
|
-
raise
|
|
291
|
+
secure_atomic.atomic_write_bytes(path, payload, mode=mode, parent_mode=0o700)
|
|
320
292
|
|
|
321
293
|
|
|
322
294
|
def _canonical(payload: Mapping[str, object]) -> bytes:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# BugX Supervisor (并发协调与智能体调度仲裁中心)
|
|
2
2
|
|
|
3
|
-
> **版本契约**: `0.1.
|
|
3
|
+
> **版本契约**: `0.1.5` | **所属分层**: `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
|
|
|
@@ -20,6 +20,8 @@ from contextlib import contextmanager
|
|
|
20
20
|
from pathlib import Path
|
|
21
21
|
from typing import Callable, Mapping
|
|
22
22
|
|
|
23
|
+
import core.secure_atomic as secure_atomic
|
|
24
|
+
|
|
23
25
|
try:
|
|
24
26
|
import fcntl
|
|
25
27
|
except ImportError: # pragma: no cover
|
|
@@ -73,30 +75,7 @@ def _fsync_dir(path: Path) -> None:
|
|
|
73
75
|
|
|
74
76
|
|
|
75
77
|
def _atomic_bytes(path: Path, data: bytes, *, mode: int = 0o600) -> None:
|
|
76
|
-
|
|
77
|
-
try:
|
|
78
|
-
os.chmod(path.parent, 0o700)
|
|
79
|
-
except OSError:
|
|
80
|
-
pass
|
|
81
|
-
descriptor, temporary = tempfile.mkstemp(prefix=f".{path.name}.", dir=str(path.parent))
|
|
82
|
-
try:
|
|
83
|
-
os.fchmod(descriptor, mode)
|
|
84
|
-
with os.fdopen(descriptor, "wb") as handle:
|
|
85
|
-
handle.write(data)
|
|
86
|
-
handle.flush()
|
|
87
|
-
os.fsync(handle.fileno())
|
|
88
|
-
os.replace(temporary, path)
|
|
89
|
-
_fsync_dir(path.parent)
|
|
90
|
-
except BaseException:
|
|
91
|
-
try:
|
|
92
|
-
os.close(descriptor)
|
|
93
|
-
except OSError:
|
|
94
|
-
pass
|
|
95
|
-
try:
|
|
96
|
-
os.unlink(temporary)
|
|
97
|
-
except OSError:
|
|
98
|
-
pass
|
|
99
|
-
raise
|
|
78
|
+
secure_atomic.atomic_write_bytes(path, data, mode=mode, parent_mode=0o700)
|
|
100
79
|
|
|
101
80
|
|
|
102
81
|
def _safe_participant(root: Path, path: Path) -> Path:
|
|
@@ -1334,6 +1334,8 @@ class ZombieDetector:
|
|
|
1334
1334
|
才允许 ``os.killpg``,否则退化为对单个 PID 发信号,避免一次终止波及
|
|
1335
1335
|
整组无关进程。
|
|
1336
1336
|
"""
|
|
1337
|
+
if not hasattr(os, "getpgid") or not hasattr(os, "getsid"):
|
|
1338
|
+
return False
|
|
1337
1339
|
try:
|
|
1338
1340
|
return os.getpgid(pid) == pid and os.getsid(pid) == pid
|
|
1339
1341
|
except OSError:
|
|
@@ -1450,10 +1452,11 @@ class ZombieDetector:
|
|
|
1450
1452
|
while ZombieDetector.is_pid_alive(pid) and time.monotonic() < deadline:
|
|
1451
1453
|
time.sleep(0.02)
|
|
1452
1454
|
if ZombieDetector.is_pid_alive(pid):
|
|
1455
|
+
sigkill = getattr(signal, "SIGKILL", signal.SIGTERM)
|
|
1453
1456
|
try:
|
|
1454
|
-
signal_target(
|
|
1457
|
+
signal_target(sigkill)
|
|
1455
1458
|
except OSError:
|
|
1456
|
-
os.kill(pid,
|
|
1459
|
+
os.kill(pid, sigkill)
|
|
1457
1460
|
terminated = not ZombieDetector.is_pid_alive(pid)
|
|
1458
1461
|
return terminated, ("" if terminated else "signal_failed")
|
|
1459
1462
|
except (OSError, subprocess.SubprocessError):
|
|
@@ -84,10 +84,23 @@ def terminate_group(process: subprocess.Popen[bytes]) -> None:
|
|
|
84
84
|
# 即使父进程已经退出,后台孙进程仍可能保留该进程组;必须
|
|
85
85
|
# 继续清理整个组,避免它们脱离 Worker 生命周期。
|
|
86
86
|
os.killpg(process.pid, signal.SIGTERM)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
else: # pragma: no cover - Windows fallback
|
|
88
|
+
# Do not invoke an asynchronous tree-kill command here: a delayed
|
|
89
|
+
# PID-based command can target an unrelated process after PID
|
|
90
|
+
# reuse. The caller owns the exact ACP parent and closes its pipes.
|
|
91
|
+
if process.poll() is None:
|
|
92
|
+
process.terminate()
|
|
93
|
+
except (OSError, ProcessLookupError, subprocess.TimeoutExpired):
|
|
90
94
|
pass
|
|
95
|
+
if os.name == "nt": # pragma: no cover - Windows fallback
|
|
96
|
+
# Windows process handles may remain non-signaled while Antigravity's
|
|
97
|
+
# child MCP pipes drain. Never wait on that handle in the teardown
|
|
98
|
+
# path: kill this exact parent and return.
|
|
99
|
+
try:
|
|
100
|
+
process.kill()
|
|
101
|
+
except (OSError, ProcessLookupError):
|
|
102
|
+
pass
|
|
103
|
+
return
|
|
91
104
|
deadline = time.monotonic() + _KILL_GRACE_SECONDS
|
|
92
105
|
while process.poll() is None and time.monotonic() < deadline:
|
|
93
106
|
time.sleep(0.02)
|
|
@@ -168,7 +168,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
168
168
|
from core.runtime.prep_validate import REQUIRED
|
|
169
169
|
print(json.dumps({"required_headings": list(REQUIRED)}, ensure_ascii=False, indent=2))
|
|
170
170
|
return 0
|
|
171
|
-
packet = json.loads(args.input.read_text() if args.input else sys.stdin.read())
|
|
171
|
+
packet = json.loads(args.input.read_text(encoding="utf-8") if args.input else sys.stdin.read())
|
|
172
172
|
if args.operation == "decode":
|
|
173
173
|
result = decode(packet)
|
|
174
174
|
elif args.operation == "summary":
|
|
@@ -176,7 +176,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
176
176
|
elif args.operation == "handoff":
|
|
177
177
|
if not args.task or not args.context:
|
|
178
178
|
raise ValueError("handoff needs --task and --context")
|
|
179
|
-
result = handoff(args.task.read_text(), decode(packet), json.loads(args.context.read_text()))
|
|
179
|
+
result = handoff(args.task.read_text(encoding="utf-8"), decode(packet), json.loads(args.context.read_text(encoding="utf-8")))
|
|
180
180
|
elif args.operation == "checkpoint":
|
|
181
181
|
result = checkpoint(packet, args.unit or "", args.note, covered=args.covered)
|
|
182
182
|
else:
|
|
@@ -358,11 +358,49 @@ def _search_docs_fts5(self, proj_root: Path, query: str) -> dict[str, Any]:
|
|
|
358
358
|
return {"ok": True, "query": "", "results": []}
|
|
359
359
|
root = proj_root.resolve()
|
|
360
360
|
results: list[dict[str, Any]] = []
|
|
361
|
+
seen_paths: set[str] = set()
|
|
361
362
|
|
|
362
|
-
#
|
|
363
|
+
# 1. 优先对接 bugx-docs 双作用域章节级 FTS5 trigram 检索引擎(DOC-006 设计项 7)
|
|
364
|
+
try:
|
|
365
|
+
from core.skills import bugx_docs_mcp_server as docs_server
|
|
366
|
+
db_path = root / ".bugx" / "knowledge" / "docs.sqlite3"
|
|
367
|
+
project_id = root.name
|
|
368
|
+
rag = docs_server.call_tool(
|
|
369
|
+
db_path,
|
|
370
|
+
"search_docs",
|
|
371
|
+
{"query": q, "limit": 20, "library_id": "all", "project_id": project_id},
|
|
372
|
+
project_id=project_id,
|
|
373
|
+
expected_token=None,
|
|
374
|
+
)
|
|
375
|
+
for item in rag.get("results") or []:
|
|
376
|
+
rel = str(item.get("source") or "")
|
|
377
|
+
if not rel:
|
|
378
|
+
continue
|
|
379
|
+
lib = str(item.get("library_id") or "")
|
|
380
|
+
key = f"{lib}:{rel}:{item.get('section') or ''}"
|
|
381
|
+
if key in seen_paths:
|
|
382
|
+
continue
|
|
383
|
+
seen_paths.add(key)
|
|
384
|
+
results.append({
|
|
385
|
+
"path": rel,
|
|
386
|
+
"name": rel.rsplit("/", 1)[-1],
|
|
387
|
+
"category": "official_docs" if lib == docs_server.OFFICIAL_LIBRARY_ID else "project_docs",
|
|
388
|
+
"library_id": lib,
|
|
389
|
+
"section": item.get("section") or "",
|
|
390
|
+
"heading_path": item.get("heading_path") or "",
|
|
391
|
+
"line": 1,
|
|
392
|
+
"snippet": str(item.get("snippet") or "")[:300],
|
|
393
|
+
})
|
|
394
|
+
except Exception:
|
|
395
|
+
pass
|
|
396
|
+
|
|
397
|
+
# 2. 补充扫描未纳入 bugx-docs 的本地报告/配置 (.bugx/ 报告及顶层配置)
|
|
363
398
|
tree = self._get_docs_tree(root)
|
|
364
399
|
q_lower = q.lower()
|
|
365
400
|
for grp in tree.get("groups", []):
|
|
401
|
+
grp_id = grp.get("id")
|
|
402
|
+
if grp_id not in {"audit_reports", "config_files"} and results:
|
|
403
|
+
continue
|
|
366
404
|
for item in grp.get("items", []):
|
|
367
405
|
rel = item["path"]
|
|
368
406
|
fpath = root / rel
|
|
@@ -384,7 +422,7 @@ def _search_docs_fts5(self, proj_root: Path, query: str) -> dict[str, Any]:
|
|
|
384
422
|
break
|
|
385
423
|
except Exception:
|
|
386
424
|
continue
|
|
387
|
-
return {"ok": True, "query": q, "results": results}
|
|
425
|
+
return {"ok": True, "query": q, "results": results[:50]}
|
|
388
426
|
|
|
389
427
|
def _list_fs(self, sub_path: str) -> dict[str, Any]:
|
|
390
428
|
"""List subdirectories and files in sub_path (supports ~, absolute, and relative paths)."""
|
|
@@ -383,7 +383,7 @@ def _default_mcp_command(name: str, reg_entry: dict[str, Any]) -> tuple[str, lis
|
|
|
383
383
|
if name == "bugx-supervisor-worker":
|
|
384
384
|
return "bugx", ["mcp", "serve", "--root", ".", "--role", "worker"]
|
|
385
385
|
if name == "bugx-docs":
|
|
386
|
-
return "bugx", ["mcp", "serve", "--root", ".", "--
|
|
386
|
+
return "bugx", ["mcp", "docs", "serve", "--root", ".", "--db", ".bugx/knowledge/docs.sqlite3"]
|
|
387
387
|
if name in ONLINE_MCP_CATALOG:
|
|
388
388
|
on_item = ONLINE_MCP_CATALOG[name]
|
|
389
389
|
return str(on_item.get("command") or "npx"), list(on_item.get("args") or [])
|
|
@@ -482,7 +482,7 @@ def inspect_workspace_mcp(workspace_path: Path | str) -> dict[str, Any]:
|
|
|
482
482
|
if not servers:
|
|
483
483
|
for def_name, def_tools, def_cmd in (
|
|
484
484
|
("bugx-supervisor", 12, "bugx mcp serve --root . --role host"),
|
|
485
|
-
("bugx-docs", 4, "bugx mcp serve --root . --
|
|
485
|
+
("bugx-docs", 4, "bugx mcp docs serve --root . --db .bugx/knowledge/docs.sqlite3"),
|
|
486
486
|
):
|
|
487
487
|
is_dis = def_name in disabled_mcps
|
|
488
488
|
servers.append({
|
|
@@ -536,10 +536,10 @@ MCP_TOOLS_CATALOG: dict[str, list[dict[str, str]]] = {
|
|
|
536
536
|
{"name": "bugx_supervisor_status", "description": "查询 Supervisor 全局健康状态与运行指标", "parameters": "verbose"},
|
|
537
537
|
],
|
|
538
538
|
"bugx-docs": [
|
|
539
|
-
{"name": "
|
|
540
|
-
{"name": "
|
|
541
|
-
{"name": "
|
|
542
|
-
{"name": "
|
|
539
|
+
{"name": "resolve_library", "description": "解析当前项目或 BugX 官方受控文档库", "parameters": "name, project_id"},
|
|
540
|
+
{"name": "search_docs", "description": "在官方与当前项目文档章节级 FTS5 trigram 索引中检索", "parameters": "query, project_id, library_id, limit"},
|
|
541
|
+
{"name": "fetch_doc", "description": "高效只读读取指定文档或精确章节(保留子标题完整边界)", "parameters": "document_id, section, project_id"},
|
|
542
|
+
{"name": "list_sections", "description": "获取文档完整 Markdown 标题目录 (TOC) 与字符估算", "parameters": "document_id, project_id"},
|
|
543
543
|
],
|
|
544
544
|
"postmcp": [
|
|
545
545
|
{"name": "postmcp_http_request", "description": "构造并执行受控 HTTP/REST 请求(支持全动词)", "parameters": "url, method, headers, body, timeout"},
|
|
@@ -1,69 +1,69 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: bugx
|
|
3
|
-
description:
|
|
3
|
+
description: BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。
|
|
4
4
|
---
|
|
5
|
-
<!-- bugx-locale:
|
|
5
|
+
<!-- bugx-locale: zh-CN -->
|
|
6
6
|
|
|
7
7
|
# BugX
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
这是 BugX 的 Cline 项目级 Skill 入口。先读取全局引擎协议:通过 `bugx engine path --name bugx-runtime-contract.md` 和 `bugx engine path --name bugx-quick.md` 读取全局协议,并遵守其中的寿命、Supervisor、证据和报告协议。
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
该入口只把任务交给当前 Cline;BugX CLI 只安装资源,不启动 Cline、不执行审计。项目未被 Cline 信任时,请先在 Cline 中信任项目;进入会话后本 Skill 由项目 `.cline/skills/bugx/SKILL.md` 自动发现,也可在对话中用 `/bugx` 显式触发(Cline CLI 没有 `--agent` 启动参数)。
|
|
12
|
+
公开 Agent 模板来源:`bugx engine path --name bugx.md`。
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
## Cline
|
|
15
|
+
## Cline 原生交互适配(强制)
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
启动器必须通过 `--host cline` 将宿主写入当前会话 runtime,不得让项目中的 `opencode.json` 推断宿主。使用当前 Cline 会话提供的 `ask_question`(或宿主等价的结构化用户选择控件);按选项的唯一 `value` 及受控 `action` 执行。本入口由 Cline 项目级 Skill(`.cline/skills/bugx/SKILL.md`,Cline 自动发现或 `/bugx` 触发)加载,Cline 桌面端通过当前工作区的 BugX Skill 进入;Cline CLI 使用 `cline <prompt>`,无头自治由 CLI 的 JSON/headless 模式承载提示和会话恢复,`cline --acp` 是 ACP 服务入口,不能当作一次性 prompt 命令直接运行。Cline MCP 由安装器写入 Cline 数据目录内的 `<CLINE_DATA_DIR>/settings/cline_mcp_settings.json`(默认 `~/.cline/data/settings/cline_mcp_settings.json`)的 `mcpServers`:Cline 3.x 没有工作区级 MCP 作用域,项目内 `.cline/mcp.json` 永不被加载;必须同时存在并启用 `bugx-supervisor` 与 worker,Skill 文件不能替代 MCP。Cline 不支持 BugX 的 `Task(subagent_type="bugx-worker")` 派发契约;桌面端内置研究子 Agent不具备 Worker 写入与 MCP 权限,CLI 自带的 Agent/Team 接口也不等价于该 Task 契约。因此交互式单会话保持单 Claim 串行:运行 `bugx engine --root . workers --count 1`,再由当前会话通过 `bugx-supervisor-worker` 完成 worker-start、heartbeat/tool_call 和 checkpoint,核对有效 checkpoint 后才领取下一条。多进程 CLI/自治执行使用 `bugx autonomous --host cline --workers N` 或 workers 的显式 `--execute`,运行时上下文会把 host/execute/worker_capacity 原子写入当前项目会话,切换到 2~6 路有界进程池;每个 claim 在 `<artifact_root>/.cline_data` 中运行,注入 `CLINE_DATA_DIR` 与 `--data-dir`,仅加载 `bugx-supervisor-worker`(`--role worker`)和 `bugx-docs`,绝不加载主控 `bugx-supervisor`。进程池按 Supervisor 自适应槽位使用滑动窗口和 runtime context 的 `stagger_seconds` 错峰补位;超时、异常退出或无持久化 checkpoint 时回收该 claim,只有有效 Supervisor checkpoint 才算成功。mine 阶段只读共享源码,PoC 与证据只能写入 claim 的 artifact_root。
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## 启动交互适配:启动策略(无问卷)
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
##
|
|
22
|
+
开工策略按 CLI 参数 > 项目 `.bugx/config.json` > 用户 `~/.bugx/config.json` > 系统默认值读取。在自治启动(--autonomous)模式下,常规启动不呈现云同步、审查方式、轮询、修复或提交问卷;在非自治交互模式下,由宿主调用原生问答控件呈现作战方案供用户确认(一键批准、微调或暂存稍后)。可选 MCP/探针不可用时自动回退到 Native Protocol Mode 与内置能力,不因缺少 session proof 要求重启。
|
|
23
|
+
## 宿主路由(先于意图分流)
|
|
24
24
|
|
|
25
|
-
- **ZCode
|
|
26
|
-
-
|
|
25
|
+
- **ZCode 宿主**:优先加载同插件 `bugx-zcode` skill(ZCode 专属手册:直驱路径、rpc 回退、坑位对策)。若当前会话未注册该 skill(新装 skill 需重启宿主会话才可见),直接按其核心结论执行:`workers` 预占后**由宿主会话直驱协议通道**(worker MCP 工具或 `bugx supervisor rpc --role worker`,caller_role=worker),勿默认为 worker 派发子代理;`run_sandboxed_probe` 必须携带本次 Task 的 lease_id/execution_id。
|
|
26
|
+
- 其余宿主按后续章节执行。
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
##
|
|
30
|
+
## 如何使用本技能(AI 执行元指南与意图决策树)
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
当你(AI)触发并阅读本技能时,请无条件遵循以下认知模型与执行时序:
|
|
33
33
|
|
|
34
|
-
### 1.
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
34
|
+
### 1. 意图决策树(Triage Decision Tree)
|
|
35
|
+
拿到任务第一秒,判定属于哪个分支:
|
|
36
|
+
- **分支 A:单点敏捷排查 / 特定函数 / Diff / 报错堆栈**
|
|
37
|
+
- **标志**:单文件排查、复现某个函数、分析异常报错。
|
|
38
|
+
- **动作**:就地编写轻量复现脚本(PoC)或运行定向测试,使用 `bugx view`, `bugx test-generate`, `bugx test-verify`;**严禁启动重型全流程门禁!**
|
|
39
|
+
- **分支 B:全库漏洞挖掘 / 深度变异 / 多 Worker 并发审计**
|
|
40
|
+
- **标志**:用户明确输入 `/bugx`、要求“全库审计”、“挖掘潜在漏洞”。
|
|
41
|
+
- **动作**:按标准生命周期流转(`engine pre` -> 门禁确认 -> Explore -> Mutate -> Repair -> 结算)。
|
|
42
|
+
- **分支 C:环境诊断 / 依赖修复 / 宿主状态排查**
|
|
43
|
+
- **动作**:优先运行 `bugx doctor --root <ROOT> --json` 与 `bugx engine --root <ROOT> status --json`,绝不盲目 `init` 或 `--force`。
|
|
44
44
|
|
|
45
|
-
### 2.
|
|
46
|
-
1.
|
|
47
|
-
2.
|
|
48
|
-
3.
|
|
49
|
-
4.
|
|
50
|
-
5.
|
|
45
|
+
### 2. 标准五步操作闭环(5-Step Execution Loop)
|
|
46
|
+
1. **定根**:确定被测项目根绝对路径 `<ROOT>`,严格在 `<ROOT>` 内部执行,禁止全盘发散扫描。
|
|
47
|
+
2. **探况**:先执行只读命令检查运行态(`bugx engine --root <ROOT> status --json` 或 `bugx doctor`)。
|
|
48
|
+
3. **选路**:根据意图挑选命令;若需查阅参数,运行 `bugx help <顶层命令>`(如 `bugx help cloud`)按需动态读取,严禁盲猜。
|
|
49
|
+
4. **承接**:若 `engine pre` 返回退出码 `2`,表示等待宿主单选门禁交互;必须调用宿主原生控件展示选项,按用户选择的 action 执行,禁止文本伪造选择或自旋重试。退出码 `0` 只代表门禁通过,不代表挖掘完成。
|
|
50
|
+
5. **闭环**:缺陷必须给出最小独立复现脚本(PoC)与完整调用栈证据;使用 6 大标准汇报用词(只读检查、项目就绪、门禁就绪、测试执行、挖掘启动、挖掘完成)如实汇报。
|
|
51
51
|
|
|
52
|
-
### 3.
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
- **Supervisor
|
|
57
|
-
-
|
|
58
|
-
-
|
|
52
|
+
### 3. 高频场景命令(覆盖 90% 日常调用)
|
|
53
|
+
- **环境诊断**:`bugx doctor --root <ROOT> --json`(`--repair-assets` 按需修复)
|
|
54
|
+
- **启动与门禁**:先运行 `bugx engine --root <ROOT> status --json`;仅当状态为 `UNINITIALIZED` 时运行 `bugx engine --root <ROOT> pre` 自动准备新项目。挖掘启动不要先调用 `bugx init`;它是独立 CLI 初始化操作,不替代 status/pre 状态机。若状态为 `FATAL_BLOCKED`、其他阻断状态或检查失败,保留现场并停止;禁止用 `init`、`reset` 或 `--force` 绕过门禁。
|
|
55
|
+
- **单点复现与变异**:`bugx test-generate --root <ROOT> --scope <PATH::SYM> --out <FILE>` / `bugx test-verify verify --scope <SCOPE>`
|
|
56
|
+
- **Supervisor 与并发排查**:`bugx supervisor status --root <ROOT>`
|
|
57
|
+
- **脱敏飞轮与日志**:`bugx telemetry inspect` / `bugx log --root <ROOT> --errors`
|
|
58
|
+
- **双轨报告与预览**:`bugx report both --eval-dir verification/evals/oss --out verification/evals/oss` / `bugx report serve --port 18991`
|
|
59
59
|
|
|
60
|
-
### 4.
|
|
61
|
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
60
|
+
### 4. 紧凑型命令全景雷达(43 个顶层命令分类索引)
|
|
61
|
+
如需调用以下命令,通过 `bugx help <命令>` 动态获取具体参数与子命令,严禁盲猜:
|
|
62
|
+
- **诊断与探索 (10)**:`help`, `completion`, `guide`, `hosts`, `doctor`, `log`, `stats`, `view`, `project`, `self-audit`
|
|
63
|
+
- **核心生命周期与宿主 (15)**:`init`, `install`, `reset`, `uninstall`, `dsh`, `engine`, `supervisor`, `daemon`, `config`, `plugin`, `mcp`, `capability`, `mcp-runtime`, `update`, `interaction`
|
|
64
|
+
- **深度审计与测试验证 (10)**:`audit`, `probe`, `logic-analysis`, `mining-audit`, `test-generate`, `test-audit`, `test-verify`, `patch-forge`, `autonomous`, `goal`
|
|
65
|
+
- **云端、知识与交付 (8)**:`cloud`, `auth`, `telemetry`, `knowledge`, `lesson`, `skill`, `advisory`, `report`
|
|
66
66
|
|
|
67
|
-
### 5.
|
|
68
|
-
-
|
|
69
|
-
-
|
|
67
|
+
### 5. 核心军规与废弃命令重定向
|
|
68
|
+
- **阻断不授权暴力修复**:`FATAL_BLOCKED` 严禁使用 `init`、`reset`、`--force` 绕过,先保留报告和日志。
|
|
69
|
+
- **废弃命令重定向**:`matrix` -> `bugx audit`;`console` -> `bugx report serve`;`watch` -> `bugx log --watch`;`test` 不是公共命令。开发验证请在仓库外生成最小临时验证脚本,或运行被测目标项目自带的测试,完成后删除过程文件。
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: bugx
|
|
3
|
-
description:
|
|
3
|
+
description: BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。
|
|
4
4
|
---
|
|
5
|
+
<!-- bugx-locale: zh-CN -->
|
|
5
6
|
|
|
6
7
|
# BugX Agent for DeepSeek Harness (dsh)
|
|
7
8
|
|
|
@@ -58,12 +58,12 @@ Skill、MCP `--root` 与证据输出都绑定当前 Session 的 workspace cwd;
|
|
|
58
58
|
- **脱敏飞轮与日志**:`bugx telemetry inspect` / `bugx log --root <ROOT> --errors`
|
|
59
59
|
- **双轨报告与预览**:`bugx report both --eval-dir evals/oss --out evals/oss` / `bugx report serve --port 18991`
|
|
60
60
|
|
|
61
|
-
### 4. 紧凑型命令全景雷达(
|
|
61
|
+
### 4. 紧凑型命令全景雷达(43 个顶层命令分类索引)
|
|
62
62
|
如需调用以下命令,通过 `bugx help <命令>` 动态获取具体参数与子命令,严禁盲猜:
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
63
|
+
- **诊断与探索 (10)**:`help`, `completion`, `guide`, `hosts`, `doctor`, `log`, `stats`, `view`, `project`, `self-audit`
|
|
64
|
+
- **核心生命周期与宿主 (15)**:`init`, `install`, `reset`, `uninstall`, `dsh`, `engine`, `supervisor`, `daemon`, `config`, `plugin`, `mcp`, `capability`, `mcp-runtime`, `update`, `interaction`
|
|
65
|
+
- **深度审计与测试验证 (10)**:`audit`, `probe`, `logic-analysis`, `mining-audit`, `test-generate`, `test-audit`, `test-verify`, `patch-forge`, `autonomous`, `goal`
|
|
66
|
+
- **云端、知识与交付 (8)**:`cloud`, `auth`, `telemetry`, `knowledge`, `lesson`, `skill`, `advisory`, `report`
|
|
67
67
|
|
|
68
68
|
### 5. 核心军规与废弃命令重定向
|
|
69
69
|
- **阻断不授权暴力修复**:`FATAL_BLOCKED` 严禁使用 `init`、`reset`、`--force` 绕过,先保留报告和日志。
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema_version": 1,
|
|
3
3
|
"name": "bugx-built-in-mcp",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.5",
|
|
5
5
|
"servers": {
|
|
6
6
|
"bugx-supervisor": {
|
|
7
7
|
"type": "builtin",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"host"
|
|
16
16
|
],
|
|
17
17
|
"source": "core/skills/bugx_mcp_server.py",
|
|
18
|
-
"sha256": "
|
|
18
|
+
"sha256": "5a6114314b55840a04760300aa748cbdad9d771096e60ced2b24c45376373ec9",
|
|
19
19
|
"health": "initialize"
|
|
20
20
|
},
|
|
21
21
|
"bugx-supervisor-worker": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"worker"
|
|
31
31
|
],
|
|
32
32
|
"source": "core/skills/bugx_mcp_server.py",
|
|
33
|
-
"sha256": "
|
|
33
|
+
"sha256": "5a6114314b55840a04760300aa748cbdad9d771096e60ced2b24c45376373ec9",
|
|
34
34
|
"health": "initialize"
|
|
35
35
|
},
|
|
36
36
|
"bugx-docs": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
".bugx/knowledge/docs.sqlite3"
|
|
47
47
|
],
|
|
48
48
|
"source": "core/skills/bugx_docs_mcp_server.py",
|
|
49
|
-
"sha256": "
|
|
49
|
+
"sha256": "7c71427c782371c9591e52e15161cf6896031c8016917565eaca91620b31bf52",
|
|
50
50
|
"health": "initialize"
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -57,12 +57,12 @@ Pi 的 `.pi/extensions/bugx` 提供原生选择能力;`BUGX_INTERACTION_REQUES
|
|
|
57
57
|
- **脱敏飞轮与日志**:`bugx telemetry inspect` / `bugx log --root <ROOT> --errors`
|
|
58
58
|
- **双轨报告与预览**:`bugx report both --eval-dir evals/oss --out evals/oss` / `bugx report serve --port 18991`
|
|
59
59
|
|
|
60
|
-
### 4. 紧凑型命令全景雷达(
|
|
60
|
+
### 4. 紧凑型命令全景雷达(43 个顶层命令分类索引)
|
|
61
61
|
如需调用以下命令,通过 `bugx help <命令>` 动态获取具体参数与子命令,严禁盲猜:
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
62
|
+
- **诊断与探索 (10)**:`help`, `completion`, `guide`, `hosts`, `doctor`, `log`, `stats`, `view`, `project`, `self-audit`
|
|
63
|
+
- **核心生命周期与宿主 (15)**:`init`, `install`, `reset`, `uninstall`, `dsh`, `engine`, `supervisor`, `daemon`, `config`, `plugin`, `mcp`, `capability`, `mcp-runtime`, `update`, `interaction`
|
|
64
|
+
- **深度审计与测试验证 (10)**:`audit`, `probe`, `logic-analysis`, `mining-audit`, `test-generate`, `test-audit`, `test-verify`, `patch-forge`, `autonomous`, `goal`
|
|
65
|
+
- **云端、知识与交付 (8)**:`cloud`, `auth`, `telemetry`, `knowledge`, `lesson`, `skill`, `advisory`, `report`
|
|
66
66
|
|
|
67
67
|
### 5. 核心军规与废弃命令重定向
|
|
68
68
|
- **阻断不授权暴力修复**:`FATAL_BLOCKED` 严禁使用 `init`、`reset`、`--force` 绕过,先保留报告和日志。
|