bugx-cli 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -35
- package/core/README.md +1 -1
- package/core/agent/agent_orchestrator.py +3 -0
- package/core/agent/agent_workspace.py +14 -2
- package/core/assets/README.md +3 -2
- package/core/assets/bugx-social-preview.svg +71 -0
- package/core/assets/bugx-wechat-group.png +0 -0
- package/core/assets/twitter_promo_art.jpg +0 -0
- package/core/assets/twitter_promo_card.svg +166 -0
- package/core/assets/twitter_promo_clean.jpg +0 -0
- package/core/assets/twitter_terminal_real.png +0 -0
- package/core/audit_packs/README.md +2 -0
- package/core/audit_packs/pitfalls/auth_crypto.json +64 -0
- package/core/audit_packs/pitfalls/file_ssrf_cmd.json +64 -0
- package/core/audit_packs/pitfalls/go_backend.json +66 -0
- package/core/audit_packs/pitfalls/java_spring.json +64 -0
- package/core/audit_packs/pitfalls/js_ts_web.json +67 -0
- package/core/audit_packs/pitfalls/python_web.json +82 -0
- package/core/bugx.md +2 -2
- package/core/bugx_paths.py +2 -2
- package/core/cli-help.txt +1 -1
- package/core/cloud_sync/cloud_client.py +56 -5
- package/core/cloud_sync/consent.py +33 -3
- package/core/cloud_sync/flywheel_client.py +186 -24
- package/core/contracts/README.md +1 -1
- package/core/contracts/bugx-opencode.md +1 -1
- package/core/contracts/bugx-runtime-contract.md +1 -1
- package/core/contracts/bugx-worker.md +1 -1
- package/core/engine-integrity.json +191 -95
- package/core/host_acp/kimi.py +175 -0
- package/core/host_acp/minimax.py +28 -0
- package/core/host_runtime/host_registry.py +23 -3
- package/core/hosts/dsh.py +1 -1
- package/core/hosts/kimi.py +293 -0
- package/core/hosts/minimax.py +248 -0
- package/core/hosts/zcode.py +5 -0
- package/core/infra/README.md +1 -1
- package/core/infra/build_info.py +30 -5
- package/core/launch_phases/README.md +6 -3
- package/core/launch_phases/finding_confirm_phase.py +168 -7
- package/core/launch_phases/post_phase.py +5 -5
- package/core/launch_phases/pre_recon_scout.py +13 -0
- package/core/launch_phases/report_sharing.py +3 -7
- package/core/launch_phases/round_orchestrator.py +114 -26
- package/core/launch_phases/semantic_recon.py +545 -0
- package/core/launch_phases/startup_version_gate.py +6 -2
- package/core/launch_phases/supervisor_bridge.py +14 -23
- package/core/launch_phases/verify_loop.py +767 -0
- package/core/launch_phases/worker_prior.py +115 -0
- package/core/ledger/README.md +2 -1
- package/core/ledger/finding_verification.py +511 -2
- package/core/ledger/fp_ledger.py +255 -0
- package/core/metadata.txt +2 -2
- package/core/planning/README.md +2 -1
- package/core/planning/prompt_harness.py +50 -10
- package/core/planning/prompt_policy_engine.py +386 -0
- package/core/prompts/README.md +4 -2
- package/core/prompts/policies/prompt_policies.json +101 -0
- package/core/prompts/stages/stage_verify.defensive.md +42 -0
- package/core/prompts/stages/stage_verify.md +44 -0
- package/core/report_engine/report_share.py +0 -8
- package/core/retrieval/README.md +2 -1
- package/core/retrieval/pitfall_packs.py +277 -0
- package/core/runtime/README.md +1 -1
- package/core/runtime/global_telemetry.py +20 -0
- package/core/runtime/scenario_eval.py +1 -1
- package/core/runtime/setup_ui_env.py +4 -7
- package/core/supervisor/README.md +1 -1
- package/core/supervisor/cli.py +2 -2
- package/core/webui/mcp_inspector.py +6 -0
- package/core/webui/static/index.html +51 -3
- package/core/webui/static/manifest.webmanifest +1 -1
- package/core/webui/static/project-settings.js +18 -3
- package/core/webui/static/robots.txt +36 -0
- package/core/webui/static/sitemap.xml +15 -0
- package/docs/07_distribution/01_README_NPM.md +36 -35
- package/ecosystem/integrations/cline/skills/bugx/SKILL.md +1 -1
- package/ecosystem/integrations/dsh/agents/bugx.md +1 -1
- package/ecosystem/integrations/dsh/dsh-patch.yml +2 -2
- package/ecosystem/integrations/dsh/mcp/package.json +1 -1
- package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +1 -1
- package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +1 -1
- package/ecosystem/integrations/dsh/ui/package.json +1 -1
- package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +1 -1
- package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
- package/ecosystem/integrations/pi/skills/bugx/SKILL.md +1 -1
- package/ecosystem/integrations/qoder/connector-meta.json +9 -9
- package/ecosystem/integrations/workbuddy/connector-meta.json +9 -9
- package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +2 -2
- package/ecosystem/plugins/bugx/.claude-plugin/marketplace.json +2 -2
- package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +2 -2
- package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +4 -4
- package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +2 -2
- package/ecosystem/plugins/bugx/agents/bugx-worker.md +1 -1
- package/ecosystem/plugins/bugx/agents/bugx.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +3 -3
- package/ecosystem/plugins/bugx/skills/bugx-claude/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +1 -1
- package/interfaces/bin/bugx.js +9 -7
- package/interfaces/cli/bugx_cli/__init__.py +2 -2
- package/interfaces/cli/bugx_cli/cli.py +178 -67
- package/interfaces/cli/bugx_cli/commands/agent.py +313 -127
- package/interfaces/cli/bugx_cli/commands/audit.py +8 -7
- package/interfaces/cli/bugx_cli/commands/cloud.py +27 -19
- package/interfaces/cli/bugx_cli/commands/doctor.py +18 -0
- package/interfaces/cli/bugx_cli/commands/knowledge.py +3 -4
- package/interfaces/cli/bugx_cli/commands/lifecycle.py +54 -47
- package/interfaces/cli/bugx_cli/commands/plugin.py +9 -9
- package/interfaces/cli/bugx_cli/commands/plugin_claude.py +27 -13
- package/interfaces/cli/bugx_cli/commands/plugin_kimi.py +348 -0
- package/interfaces/cli/bugx_cli/commands/plugin_minimax.py +322 -0
- package/interfaces/cli/bugx_cli/commands/plugin_qoder.py +3 -4
- package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +4 -5
- package/interfaces/cli/bugx_cli/commands/project.py +6 -13
- package/interfaces/cli/bugx_cli/commands/system.py +577 -162
- package/interfaces/cli/bugx_cli/common.py +102 -15
- package/interfaces/cli/bugx_cli/host_adapters.py +150 -4
- package/interfaces/cli/bugx_cli/hosts/registry.py +4 -2
- package/interfaces/cli/bugx_cli/hosts/template_engine.py +10 -9
- package/interfaces/cli/bugx_cli/infra/engine_installer.py +21 -10
- package/interfaces/cli/bugx_cli/infra/host_sync.py +1 -1
- package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +2 -2
- package/package.json +54 -16
- package/pyproject.toml +64 -1
- package/scripts/sync-version.mjs +1 -1
- package/skills/README.md +25 -0
- package/skills/platform/bugx-user/SKILL.md +92 -0
- package/core/assets/bugx-hero-cn.png +0 -0
- package/core/assets/bugx-hero-en.png +0 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""core/retrieval/pitfall_packs.py — 按技术栈按需挂载的冷启动漏洞先验包检索引擎(P1 / T-005)。
|
|
3
|
+
|
|
4
|
+
零第三方依赖实现:
|
|
5
|
+
1. 加载并校验 ``core/audit_packs/pitfalls/*.json``;
|
|
6
|
+
2. 基于 ``project_profile``(``languages`` / ``frameworks`` / ``surfaces``)及可选文件扩展名
|
|
7
|
+
执行技术栈硬过滤,杜绝跨语言噪声污染;
|
|
8
|
+
3. 双路倒数排名融合(RRF):通道 A(技术栈与严重度先验)+ 通道 B(源码反模式信号命中度);
|
|
9
|
+
4. 严格按 ``char_budget`` 渲染紧凑引导块供 ``worker_prior`` 注入。
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import json
|
|
15
|
+
from dataclasses import dataclass
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
from typing import Any, Mapping, Sequence
|
|
18
|
+
|
|
19
|
+
DEFAULT_PITFALLS_DIR = Path(__file__).resolve().parents[1] / "audit_packs" / "pitfalls"
|
|
20
|
+
RRF_K = 60.0
|
|
21
|
+
|
|
22
|
+
_REQUIRED_FIELDS = (
|
|
23
|
+
"pitfall_id",
|
|
24
|
+
"cwe",
|
|
25
|
+
"severity",
|
|
26
|
+
"languages",
|
|
27
|
+
"frameworks",
|
|
28
|
+
"surfaces",
|
|
29
|
+
"title",
|
|
30
|
+
"anti_pattern_signals",
|
|
31
|
+
"false_positive_guards",
|
|
32
|
+
"poc_skeleton",
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
_SEVERITY_WEIGHT = {
|
|
36
|
+
"critical": 4.0,
|
|
37
|
+
"high": 3.0,
|
|
38
|
+
"medium": 2.0,
|
|
39
|
+
"low": 1.0,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
_EXT_TO_LANGUAGE = {
|
|
43
|
+
".py": "python",
|
|
44
|
+
".pyi": "python",
|
|
45
|
+
".js": "javascript",
|
|
46
|
+
".mjs": "javascript",
|
|
47
|
+
".cjs": "javascript",
|
|
48
|
+
".jsx": "javascript",
|
|
49
|
+
".ts": "typescript",
|
|
50
|
+
".tsx": "typescript",
|
|
51
|
+
".go": "go",
|
|
52
|
+
".java": "java",
|
|
53
|
+
".kt": "kotlin",
|
|
54
|
+
".kts": "kotlin",
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class PitfallPackError(ValueError):
|
|
59
|
+
"""Raised when a pitfall pack JSON violates schema requirements."""
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@dataclass(frozen=True)
|
|
63
|
+
class PitfallEntry:
|
|
64
|
+
pack_id: str
|
|
65
|
+
pitfall_id: str
|
|
66
|
+
cwe: str
|
|
67
|
+
severity: str
|
|
68
|
+
languages: tuple[str, ...]
|
|
69
|
+
frameworks: tuple[str, ...]
|
|
70
|
+
surfaces: tuple[str, ...]
|
|
71
|
+
title: str
|
|
72
|
+
anti_pattern_signals: tuple[str, ...]
|
|
73
|
+
false_positive_guards: tuple[str, ...]
|
|
74
|
+
poc_skeleton: str
|
|
75
|
+
|
|
76
|
+
def to_dict(self) -> dict[str, Any]:
|
|
77
|
+
return {
|
|
78
|
+
"pack_id": self.pack_id,
|
|
79
|
+
"pitfall_id": self.pitfall_id,
|
|
80
|
+
"cwe": self.cwe,
|
|
81
|
+
"severity": self.severity,
|
|
82
|
+
"languages": list(self.languages),
|
|
83
|
+
"frameworks": list(self.frameworks),
|
|
84
|
+
"surfaces": list(self.surfaces),
|
|
85
|
+
"title": self.title,
|
|
86
|
+
"anti_pattern_signals": list(self.anti_pattern_signals),
|
|
87
|
+
"false_positive_guards": list(self.false_positive_guards),
|
|
88
|
+
"poc_skeleton": self.poc_skeleton,
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _norm_tokens(values: object) -> tuple[str, ...]:
|
|
93
|
+
if isinstance(values, str):
|
|
94
|
+
values = [values]
|
|
95
|
+
if not isinstance(values, Sequence) or isinstance(values, (str, bytes)):
|
|
96
|
+
return ()
|
|
97
|
+
out: list[str] = []
|
|
98
|
+
for item in values:
|
|
99
|
+
if isinstance(item, str) and item.strip():
|
|
100
|
+
norm = item.strip().lower()
|
|
101
|
+
if norm not in out:
|
|
102
|
+
out.append(norm)
|
|
103
|
+
return tuple(out)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def load_pitfall_packs(packs_dir: Path | None = None) -> tuple[PitfallEntry, ...]:
|
|
107
|
+
"""Load and strictly validate all cold-start pitfall JSON packs."""
|
|
108
|
+
root = Path(packs_dir) if packs_dir is not None else DEFAULT_PITFALLS_DIR
|
|
109
|
+
if not root.is_dir():
|
|
110
|
+
raise PitfallPackError(f"pitfall packs directory not found: {root}")
|
|
111
|
+
entries: list[PitfallEntry] = []
|
|
112
|
+
seen_ids: set[str] = set()
|
|
113
|
+
for path in sorted(root.glob("*.json")):
|
|
114
|
+
try:
|
|
115
|
+
payload = json.loads(path.read_text(encoding="utf-8"))
|
|
116
|
+
except (OSError, ValueError) as exc:
|
|
117
|
+
raise PitfallPackError(f"invalid pitfall pack JSON {path.name}: {exc}") from exc
|
|
118
|
+
if not isinstance(payload, Mapping) or not isinstance(payload.get("pitfalls"), list):
|
|
119
|
+
raise PitfallPackError(f"{path.name} must contain a 'pitfalls' list")
|
|
120
|
+
pack_id = str(payload.get("pack_id") or path.stem).strip()
|
|
121
|
+
for raw in payload["pitfalls"]:
|
|
122
|
+
if not isinstance(raw, Mapping):
|
|
123
|
+
raise PitfallPackError(f"{path.name} contains non-object pitfall entry")
|
|
124
|
+
missing = [f for f in _REQUIRED_FIELDS if not raw.get(f)]
|
|
125
|
+
if missing:
|
|
126
|
+
raise PitfallPackError(f"{path.name} entry missing required fields: {missing}")
|
|
127
|
+
pid = str(raw["pitfall_id"]).strip()
|
|
128
|
+
if pid in seen_ids:
|
|
129
|
+
raise PitfallPackError(f"duplicate pitfall_id detected: {pid}")
|
|
130
|
+
seen_ids.add(pid)
|
|
131
|
+
entries.append(
|
|
132
|
+
PitfallEntry(
|
|
133
|
+
pack_id=pack_id,
|
|
134
|
+
pitfall_id=pid,
|
|
135
|
+
cwe=str(raw["cwe"]).strip(),
|
|
136
|
+
severity=str(raw["severity"]).strip().lower(),
|
|
137
|
+
languages=_norm_tokens(raw["languages"]),
|
|
138
|
+
frameworks=_norm_tokens(raw["frameworks"]),
|
|
139
|
+
surfaces=_norm_tokens(raw["surfaces"]),
|
|
140
|
+
title=str(raw["title"]).strip(),
|
|
141
|
+
anti_pattern_signals=tuple(
|
|
142
|
+
str(s) for s in raw["anti_pattern_signals"] if isinstance(s, str) and s.strip()
|
|
143
|
+
),
|
|
144
|
+
false_positive_guards=tuple(
|
|
145
|
+
str(g).strip() for g in raw["false_positive_guards"] if isinstance(g, str) and g.strip()
|
|
146
|
+
),
|
|
147
|
+
poc_skeleton=str(raw["poc_skeleton"]).strip(),
|
|
148
|
+
)
|
|
149
|
+
)
|
|
150
|
+
return tuple(entries)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _infer_languages_from_path(file_path: str) -> set[str]:
|
|
154
|
+
if not file_path:
|
|
155
|
+
return set()
|
|
156
|
+
ext = Path(file_path).suffix.lower()
|
|
157
|
+
lang = _EXT_TO_LANGUAGE.get(ext)
|
|
158
|
+
return {lang} if lang else set()
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def match_pitfalls(
|
|
162
|
+
profile: Mapping[str, Any] | None = None,
|
|
163
|
+
*,
|
|
164
|
+
code_text: str = "",
|
|
165
|
+
file_path: str = "",
|
|
166
|
+
limit: int = 6,
|
|
167
|
+
packs_dir: Path | None = None,
|
|
168
|
+
) -> list[dict[str, Any]]:
|
|
169
|
+
"""Retrieve Top-K stack-matched cold-start pitfalls via dual-channel RRF."""
|
|
170
|
+
if limit <= 0:
|
|
171
|
+
return []
|
|
172
|
+
entries = load_pitfall_packs(packs_dir=packs_dir)
|
|
173
|
+
prof = profile if isinstance(profile, Mapping) else {}
|
|
174
|
+
langs = set(_norm_tokens(prof.get("languages"))) | _infer_languages_from_path(file_path)
|
|
175
|
+
frameworks = set(_norm_tokens(prof.get("frameworks")))
|
|
176
|
+
surfaces = set(_norm_tokens(prof.get("surfaces")))
|
|
177
|
+
code_lower = (code_text or "").lower()
|
|
178
|
+
|
|
179
|
+
# 1. Hard stack filter (prevent cross-language contamination)
|
|
180
|
+
eligible: list[tuple[PitfallEntry, float, int, list[str]]] = []
|
|
181
|
+
for entry in entries:
|
|
182
|
+
is_generic = "*" in entry.languages
|
|
183
|
+
if not is_generic:
|
|
184
|
+
if langs and not (langs & set(entry.languages)):
|
|
185
|
+
continue
|
|
186
|
+
if not langs and frameworks and not (frameworks & set(entry.frameworks)):
|
|
187
|
+
continue
|
|
188
|
+
|
|
189
|
+
matched_signals = [
|
|
190
|
+
sig for sig in entry.anti_pattern_signals
|
|
191
|
+
if sig.lower() in code_lower
|
|
192
|
+
]
|
|
193
|
+
# Generic cross-language packs require surface or signal match to avoid noise
|
|
194
|
+
if is_generic and not matched_signals and not (surfaces & set(entry.surfaces)):
|
|
195
|
+
continue
|
|
196
|
+
|
|
197
|
+
fw_overlap = len(frameworks & set(entry.frameworks)) if "*" not in entry.frameworks else 0
|
|
198
|
+
surf_overlap = len(surfaces & set(entry.surfaces))
|
|
199
|
+
lang_bonus = 2.0 if (not is_generic and (langs & set(entry.languages))) else 0.5
|
|
200
|
+
prior_score = (
|
|
201
|
+
_SEVERITY_WEIGHT.get(entry.severity, 1.0)
|
|
202
|
+
+ lang_bonus
|
|
203
|
+
+ (fw_overlap * 2.5)
|
|
204
|
+
+ (surf_overlap * 1.0)
|
|
205
|
+
)
|
|
206
|
+
eligible.append((entry, prior_score, len(matched_signals), matched_signals))
|
|
207
|
+
|
|
208
|
+
if not eligible:
|
|
209
|
+
return []
|
|
210
|
+
|
|
211
|
+
# 2. Dual-channel RRF fusion (Channel A: stack prior, Channel B: code signal hits)
|
|
212
|
+
rank_prior = {
|
|
213
|
+
item[0].pitfall_id: idx
|
|
214
|
+
for idx, item in enumerate(
|
|
215
|
+
sorted(eligible, key=lambda x: (-x[1], x[0].pitfall_id)), 1
|
|
216
|
+
)
|
|
217
|
+
}
|
|
218
|
+
rank_signal = {
|
|
219
|
+
item[0].pitfall_id: idx
|
|
220
|
+
for idx, item in enumerate(
|
|
221
|
+
sorted(eligible, key=lambda x: (-x[2], -x[1], x[0].pitfall_id)), 1
|
|
222
|
+
)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
fused: list[tuple[float, PitfallEntry, list[str]]] = []
|
|
226
|
+
for entry, _prior, sig_hits, matched_signals in eligible:
|
|
227
|
+
pid = entry.pitfall_id
|
|
228
|
+
# Give signal hits higher fusion weight when code_text is supplied
|
|
229
|
+
w_sig = 1.6 if sig_hits > 0 else 0.6
|
|
230
|
+
rrf_score = (1.0 / (RRF_K + rank_prior[pid])) + (w_sig / (RRF_K + rank_signal[pid]))
|
|
231
|
+
fused.append((rrf_score, entry, matched_signals))
|
|
232
|
+
|
|
233
|
+
fused.sort(key=lambda x: (-x[0], x[1].pitfall_id))
|
|
234
|
+
results: list[dict[str, Any]] = []
|
|
235
|
+
for score, entry, matched_signals in fused[:limit]:
|
|
236
|
+
item = entry.to_dict()
|
|
237
|
+
item["rrf_score"] = round(score, 6)
|
|
238
|
+
item["matched_signals"] = matched_signals
|
|
239
|
+
results.append(item)
|
|
240
|
+
return results
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def render_pitfall_guidance(
|
|
244
|
+
matches: Sequence[Mapping[str, Any]],
|
|
245
|
+
*,
|
|
246
|
+
char_budget: int = 1800,
|
|
247
|
+
) -> str:
|
|
248
|
+
"""Render compact, budget-bounded cold-start pitfall guidance for Worker prompts."""
|
|
249
|
+
if not matches or char_budget <= 0:
|
|
250
|
+
return ""
|
|
251
|
+
lines: list[str] = ["[冷启动漏洞先验雷达 (Cold-Start Pitfalls)]"]
|
|
252
|
+
used = len(lines[0]) + 1
|
|
253
|
+
for item in matches:
|
|
254
|
+
signals = ", ".join(item.get("matched_signals") or ())
|
|
255
|
+
sig_note = f" | 命中信号: {signals}" if signals else ""
|
|
256
|
+
guard = (item.get("false_positive_guards") or [""])[0]
|
|
257
|
+
block = (
|
|
258
|
+
f"- [{item.get('pitfall_id')} / {item.get('cwe')} / {str(item.get('severity', '')).upper()}] "
|
|
259
|
+
f"{item.get('title')}{sig_note}\n"
|
|
260
|
+
f" 排除条件: {guard}\n"
|
|
261
|
+
f" PoC思路: {item.get('poc_skeleton')}"
|
|
262
|
+
)
|
|
263
|
+
if used + len(block) + 1 > char_budget:
|
|
264
|
+
break
|
|
265
|
+
lines.append(block)
|
|
266
|
+
used += len(block) + 1
|
|
267
|
+
return "\n".join(lines) if len(lines) > 1 else ""
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
__all__ = [
|
|
271
|
+
"DEFAULT_PITFALLS_DIR",
|
|
272
|
+
"PitfallPackError",
|
|
273
|
+
"PitfallEntry",
|
|
274
|
+
"load_pitfall_packs",
|
|
275
|
+
"match_pitfalls",
|
|
276
|
+
"render_pitfall_guidance",
|
|
277
|
+
]
|
package/core/runtime/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# BugX Core Runtime Subsystem (核心运行时、环境与基础设施)
|
|
2
2
|
|
|
3
|
-
> **版本契约**: `0.1.
|
|
3
|
+
> **版本契约**: `0.1.2` | **所属分层**: `Layer 0: 基础设施与操作系统抽象`
|
|
4
4
|
> **工程规范**: 参见 [`docs/02_architecture/05_ARCH_NOMENCLATURE_GUIDE.md`](../../docs/02_architecture/05_ARCH_NOMENCLATURE_GUIDE.md)
|
|
5
5
|
> **守卫机制**: `scripts/verify_directory_indices.py` (100% 物理条目索引覆盖)
|
|
6
6
|
|
|
@@ -26,6 +26,22 @@ TELEMETRY_SCHEMA_VERSION = 3
|
|
|
26
26
|
logger = logging.getLogger("bugx.telemetry")
|
|
27
27
|
|
|
28
28
|
|
|
29
|
+
def _telemetry_allowed() -> bool:
|
|
30
|
+
"""Use the same user/process gate as remote telemetry.
|
|
31
|
+
|
|
32
|
+
Local statistics are still queryable after opt-out, but no new rows are
|
|
33
|
+
written once the unified telemetry switch is disabled. A missing gate is
|
|
34
|
+
treated as disabled here: recording telemetry must never bypass an
|
|
35
|
+
explicit privacy boundary because an optional import failed.
|
|
36
|
+
"""
|
|
37
|
+
try:
|
|
38
|
+
from core.cloud_sync.consent import telemetry_enabled
|
|
39
|
+
|
|
40
|
+
return bool(telemetry_enabled())
|
|
41
|
+
except Exception: # noqa: BLE001 - privacy gate fails closed
|
|
42
|
+
return False
|
|
43
|
+
|
|
44
|
+
|
|
29
45
|
def _get_db_path(override_path: Path | str | None = None) -> Path:
|
|
30
46
|
if override_path:
|
|
31
47
|
return Path(override_path).expanduser().resolve()
|
|
@@ -216,6 +232,8 @@ def record_round_telemetry(round_data: Mapping[str, Any], db_path: Path | str |
|
|
|
216
232
|
"""写入单轮次细粒度遥测记录,并原子累加当日消耗 (fail-open,不抛出异常打断审计)。"""
|
|
217
233
|
if not isinstance(round_data, Mapping) or not round_data:
|
|
218
234
|
return False
|
|
235
|
+
if not _telemetry_allowed():
|
|
236
|
+
return False
|
|
219
237
|
try:
|
|
220
238
|
init_db(db_path)
|
|
221
239
|
session_id = str(round_data.get("session_id") or round_data.get("run_id") or "standalone")
|
|
@@ -288,6 +306,8 @@ def record_session_telemetry(session_data: Mapping[str, Any], db_path: Path | st
|
|
|
288
306
|
"""写入 Session 级最终汇总记录,并原子更新当日汇总 daily_rollup (fail-open)。"""
|
|
289
307
|
if not isinstance(session_data, Mapping) or not session_data:
|
|
290
308
|
return False
|
|
309
|
+
if not _telemetry_allowed():
|
|
310
|
+
return False
|
|
291
311
|
try:
|
|
292
312
|
init_db(db_path)
|
|
293
313
|
session_id = str(session_data.get("session_id") or f"sess-{dt.datetime.now().strftime('%Y%m%d%H%M%S')}")
|
|
@@ -141,7 +141,7 @@ def _run(argv: list[str], *, cwd: Path, timeout: float = 120.0,
|
|
|
141
141
|
# L3 等场景验证当前 checkout;不让已安装的旧引擎成为量具。
|
|
142
142
|
merged["BUGX_DEV_MODE"] = "1"
|
|
143
143
|
# 源码树里的版本声明是构建模板;开发态启动门禁需要同一解析值。
|
|
144
|
-
merged["BUGX_VERSION"] = os.environ.get("BUGX_VERSION", "0.1.
|
|
144
|
+
merged["BUGX_VERSION"] = os.environ.get("BUGX_VERSION", "0.1.3")
|
|
145
145
|
merged["HOME"] = str(_sandbox_home())
|
|
146
146
|
try:
|
|
147
147
|
proc = subprocess.run(
|
|
@@ -34,8 +34,7 @@ PLAYWRIGHT_MCP_VERSION = "0.0.79"
|
|
|
34
34
|
PLAYWRIGHT_BROWSER_VERSION = "1.63.0-alpha-2026-08-05"
|
|
35
35
|
AGENT_TTY_VERSION = "0.5.0"
|
|
36
36
|
PEXPECT_VERSION = "4.9.0"
|
|
37
|
-
NODE_MIN_MAJOR =
|
|
38
|
-
NODE_MAX_MAJOR = 27
|
|
37
|
+
NODE_MIN_MAJOR = 20
|
|
39
38
|
|
|
40
39
|
|
|
41
40
|
def sh(cmd: list[str], **kw) -> subprocess.CompletedProcess:
|
|
@@ -54,10 +53,9 @@ def node_ok() -> tuple[bool, str]:
|
|
|
54
53
|
major = int(version.lstrip("v").split(".", 1)[0])
|
|
55
54
|
except ValueError:
|
|
56
55
|
return False, f"node 版本无法解析: {version}"
|
|
57
|
-
if
|
|
56
|
+
if major < NODE_MIN_MAJOR:
|
|
58
57
|
return False, (
|
|
59
|
-
f"node {version} 不兼容(固定工具链要求 "
|
|
60
|
-
f">={NODE_MIN_MAJOR}, <{NODE_MAX_MAJOR})"
|
|
58
|
+
f"node {version} 不兼容(固定工具链要求 >={NODE_MIN_MAJOR})"
|
|
61
59
|
)
|
|
62
60
|
return True, f"node {version}"
|
|
63
61
|
|
|
@@ -141,8 +139,7 @@ def install() -> int:
|
|
|
141
139
|
print("=" * 52)
|
|
142
140
|
if not node_ok()[0]:
|
|
143
141
|
print(
|
|
144
|
-
f"✗ Node.js 版本不兼容,请安装 >= {NODE_MIN_MAJOR}
|
|
145
|
-
f"< {NODE_MAX_MAJOR}(https://nodejs.org)"
|
|
142
|
+
f"✗ Node.js 版本不兼容,请安装 >= {NODE_MIN_MAJOR}(https://nodejs.org)"
|
|
146
143
|
)
|
|
147
144
|
return 1
|
|
148
145
|
npx = shutil.which("npx")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# BugX Supervisor (并发协调与智能体调度仲裁中心)
|
|
2
2
|
|
|
3
|
-
> **版本契约**: `0.1.
|
|
3
|
+
> **版本契约**: `0.1.2` | **所属分层**: `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
|
|
package/core/supervisor/cli.py
CHANGED
|
@@ -41,9 +41,9 @@ _RPC_CLIENT_INFO: Mapping[str, object] = {
|
|
|
41
41
|
|
|
42
42
|
try:
|
|
43
43
|
if hasattr(sys.stdout, "reconfigure"):
|
|
44
|
-
sys.stdout.reconfigure(line_buffering=True)
|
|
44
|
+
sys.stdout.reconfigure(line_buffering=True, encoding="utf-8", errors="replace")
|
|
45
45
|
if hasattr(sys.stderr, "reconfigure"):
|
|
46
|
-
sys.stderr.reconfigure(line_buffering=True)
|
|
46
|
+
sys.stderr.reconfigure(line_buffering=True, encoding="utf-8", errors="replace")
|
|
47
47
|
except (AttributeError, ValueError):
|
|
48
48
|
pass
|
|
49
49
|
|
|
@@ -958,6 +958,12 @@ def toggle_project_mcp(
|
|
|
958
958
|
|
|
959
959
|
res = inspect_workspace_mcp(ws)
|
|
960
960
|
res["ok"] = True
|
|
961
|
+
if mount:
|
|
962
|
+
res["session_restart_required"] = True
|
|
963
|
+
res["restart_guidance"] = (
|
|
964
|
+
"项目 MCP 配置已更新至 .mcp.json。宿主进程(VS Code / Cursor / Windsurf / Claude 等)"
|
|
965
|
+
"不支持动态热重载,必须【重载窗口 / 重启宿主会话】方可生效。"
|
|
966
|
+
)
|
|
961
967
|
res["sandbox_env_path"] = str(_sandbox_env_file(ws))
|
|
962
968
|
return res
|
|
963
969
|
|
|
@@ -6,11 +6,45 @@
|
|
|
6
6
|
name="viewport"
|
|
7
7
|
content="width=device-width,initial-scale=1,viewport-fit=cover"
|
|
8
8
|
/>
|
|
9
|
-
<title>BugX Studio ·
|
|
9
|
+
<title>BugX Studio · 自主代码审查与智能测试智能体 | 全自动黑盒/功能/性能测试与质量保障</title>
|
|
10
10
|
<meta
|
|
11
11
|
name="description"
|
|
12
|
-
content="BugX
|
|
12
|
+
content="BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:帮助开发人员在写完代码后自动排查隐藏的深层 Bug,减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;确保代码稳定运行不崩溃不卡死,上线放心不翻车。"
|
|
13
13
|
/>
|
|
14
|
+
<meta
|
|
15
|
+
name="keywords"
|
|
16
|
+
content="BugX,代码审查,自主代码审查,自动化测试,智能测试,黑盒测试,功能测试,性能测试,代码质检,软件质量保障,解放双手,Bug排查,测试智能体,AI代码审查,Claude Code,Codex,OpenCode,ZCode"
|
|
17
|
+
/>
|
|
18
|
+
<link rel="canonical" href="https://bugx.dev/" />
|
|
19
|
+
<!-- OpenGraph / Social Sharing -->
|
|
20
|
+
<meta property="og:type" content="website" />
|
|
21
|
+
<meta property="og:title" content="BugX · 自主代码审查与智能测试智能体" />
|
|
22
|
+
<meta property="og:description" content="严把代码交付关:帮助开发自动排查隐藏深层 Bug,帮助测试自动运行黑盒/功能/性能测试,确保稳定运行不崩溃不翻车,解放双手降本增效。" />
|
|
23
|
+
<meta property="og:url" content="https://bugx.dev/" />
|
|
24
|
+
<meta property="og:image" content="https://bugx.dev/icon-192.png" />
|
|
25
|
+
<meta property="og:site_name" content="BugX" />
|
|
26
|
+
<!-- Twitter Cards -->
|
|
27
|
+
<meta name="twitter:card" content="summary_large_image" />
|
|
28
|
+
<meta name="twitter:title" content="BugX · Autonomous Code Review & Automated Testing Agent" />
|
|
29
|
+
<meta name="twitter:description" content="Safeguarding software delivery: catches hidden deep bugs for developers, automates black-box, functional, and performance testing for QA, ensuring rock-solid stability." />
|
|
30
|
+
<meta name="twitter:image" content="https://bugx.dev/icon-192.png" />
|
|
31
|
+
<!-- Schema.org JSON-LD -->
|
|
32
|
+
<script type="application/ld+json">
|
|
33
|
+
{
|
|
34
|
+
"@context": "https://schema.org",
|
|
35
|
+
"@type": "SoftwareApplication",
|
|
36
|
+
"name": "BugX",
|
|
37
|
+
"operatingSystem": "All",
|
|
38
|
+
"applicationCategory": "DeveloperApplication",
|
|
39
|
+
"description": "BugX 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。",
|
|
40
|
+
"url": "https://bugx.dev",
|
|
41
|
+
"offers": {
|
|
42
|
+
"@type": "Offer",
|
|
43
|
+
"price": "0",
|
|
44
|
+
"priceCurrency": "USD"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
14
48
|
<meta name="theme-color" content="#ffffff" media="(prefers-color-scheme: light)" />
|
|
15
49
|
<meta name="theme-color" content="#151517" media="(prefers-color-scheme: dark)" />
|
|
16
50
|
<link rel="manifest" href="./manifest.webmanifest" />
|
|
@@ -50,6 +84,20 @@
|
|
|
50
84
|
<script src="./project-settings.js?v=366" defer></script>
|
|
51
85
|
</head>
|
|
52
86
|
<body>
|
|
53
|
-
<div id="app"
|
|
87
|
+
<div id="app">
|
|
88
|
+
<noscript>
|
|
89
|
+
<div style="padding: 24px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; max-width: 800px; margin: 40px auto; color: #1e293b;">
|
|
90
|
+
<h1>BugX — 自主代码审查与自主测试智能体</h1>
|
|
91
|
+
<p><strong>BugX</strong> 是一个具备自主代码审查与测试能力的智能体,严把代码交付关:它帮助开发人员在写完代码后自动排查隐藏的深层 Bug,减少反复排错与返工;帮助测试人员自动化运行黑盒测试、功能验证与性能测试,自动覆盖手工盲测难以覆盖的极端场景;确保代码功能符合要求、具备良好的健壮性和稳定性。让开发和测试在繁琐的工作中解放双手,大幅提高工作效率、全面提升代码质量、显著降低后期维护成本,实现科技服务于人。</p>
|
|
92
|
+
<h2>主要能力与适用场景</h2>
|
|
93
|
+
<ul>
|
|
94
|
+
<li><strong>代码审查(Code Review)</strong>:功能编写完成或提交 PR 时自动排查隐藏的深层逻辑缺陷与代码异味;</li>
|
|
95
|
+
<li><strong>自动化黑盒测试</strong>:在隔离沙箱中自动构造测试场景与边界用例,验证功能完备性;</li>
|
|
96
|
+
<li><strong>功能与性能验证</strong>:精准发现死锁、竞态、内存泄漏与资源未释放等深层隐患;</li>
|
|
97
|
+
<li><strong>上线前质量守门</strong>:确保交付用户的软件在复杂环境下稳定运行、不崩溃不卡死,上线放心不翻车。</li>
|
|
98
|
+
</ul>
|
|
99
|
+
</div>
|
|
100
|
+
</noscript>
|
|
101
|
+
</div>
|
|
54
102
|
</body>
|
|
55
103
|
</html>
|
|
@@ -7841,7 +7841,12 @@
|
|
|
7841
7841
|
body: JSON.stringify(payload)
|
|
7842
7842
|
});
|
|
7843
7843
|
if (res.ok) {
|
|
7844
|
-
|
|
7844
|
+
const resData = await res.json().catch(() => ({}));
|
|
7845
|
+
if (resData && resData.session_restart_required) {
|
|
7846
|
+
alert(`【必须重启宿主】已成功挂载 MCP: ${srvName}\n\n项目 MCP 配置已更新至 .mcp.json。\n宿主(VS Code / Cursor / Windsurf / Claude 等)不支持动态热加载,请务必【重载窗口 / 重启宿主会话】方可生效!`);
|
|
7847
|
+
} else {
|
|
7848
|
+
showToast(`已成功挂载 MCP: ${srvName}`);
|
|
7849
|
+
}
|
|
7845
7850
|
await this.loadData();
|
|
7846
7851
|
this.render();
|
|
7847
7852
|
} else {
|
|
@@ -8019,7 +8024,12 @@
|
|
|
8019
8024
|
if (res.ok) {
|
|
8020
8025
|
it.mounted = true;
|
|
8021
8026
|
it.enabled = true;
|
|
8022
|
-
|
|
8027
|
+
const resData = await res.json().catch(() => ({}));
|
|
8028
|
+
if (resData && resData.session_restart_required) {
|
|
8029
|
+
alert(`【必须重启宿主】已成功挂载 MCP: ${it.name}\n\n项目 MCP 配置已更新至 .mcp.json。\n宿主(VS Code / Cursor / Windsurf / Claude 等)不支持动态热加载,请务必【重载窗口 / 重启宿主会话】方可生效!`);
|
|
8030
|
+
} else {
|
|
8031
|
+
showToast(`已成功挂载 MCP: ${it.name}`);
|
|
8032
|
+
}
|
|
8023
8033
|
await this.loadData();
|
|
8024
8034
|
this.render();
|
|
8025
8035
|
} else {
|
|
@@ -8198,7 +8208,12 @@
|
|
|
8198
8208
|
})
|
|
8199
8209
|
});
|
|
8200
8210
|
if (res.ok) {
|
|
8201
|
-
|
|
8211
|
+
const resData = await res.json().catch(() => ({}));
|
|
8212
|
+
if (resData && resData.session_restart_required) {
|
|
8213
|
+
alert(`【必须重启宿主】成功挂载自定义 MCP: ${name}\n\n项目 MCP 配置已更新至 .mcp.json。\n宿主(VS Code / Cursor / Windsurf / Claude 等)不支持动态热加载,请务必【重载窗口 / 重启宿主会话】方可生效!`);
|
|
8214
|
+
} else {
|
|
8215
|
+
showToast(`成功挂载自定义 MCP: ${name}`);
|
|
8216
|
+
}
|
|
8202
8217
|
closeModal();
|
|
8203
8218
|
await this.loadData();
|
|
8204
8219
|
this.render();
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# robots.txt for BugX WebUI & Public Interface
|
|
2
|
+
User-agent: *
|
|
3
|
+
Allow: /
|
|
4
|
+
Disallow: /api/
|
|
5
|
+
Disallow: /private/
|
|
6
|
+
|
|
7
|
+
# Explicitly Allow Major Search Bots and Generative AI Answer Engines
|
|
8
|
+
User-agent: Googlebot
|
|
9
|
+
Allow: /
|
|
10
|
+
|
|
11
|
+
User-agent: Baiduspider
|
|
12
|
+
Allow: /
|
|
13
|
+
|
|
14
|
+
User-agent: Bingbot
|
|
15
|
+
Allow: /
|
|
16
|
+
|
|
17
|
+
User-agent: GPTBot
|
|
18
|
+
Allow: /
|
|
19
|
+
|
|
20
|
+
User-agent: OAI-SearchBot
|
|
21
|
+
Allow: /
|
|
22
|
+
|
|
23
|
+
User-agent: PerplexityBot
|
|
24
|
+
Allow: /
|
|
25
|
+
|
|
26
|
+
User-agent: ClaudeBot
|
|
27
|
+
Allow: /
|
|
28
|
+
|
|
29
|
+
User-agent: Applebot-Extended
|
|
30
|
+
Allow: /
|
|
31
|
+
|
|
32
|
+
User-agent: Bytespider
|
|
33
|
+
Allow: /
|
|
34
|
+
|
|
35
|
+
# Sitemap Location
|
|
36
|
+
Sitemap: https://bugx.dev/sitemap.xml
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
3
|
+
<url>
|
|
4
|
+
<loc>https://bugx.dev/</loc>
|
|
5
|
+
<lastmod>2026-11-23</lastmod>
|
|
6
|
+
<changefreq>daily</changefreq>
|
|
7
|
+
<priority>1.0</priority>
|
|
8
|
+
</url>
|
|
9
|
+
<url>
|
|
10
|
+
<loc>https://bugx.dev/docs</loc>
|
|
11
|
+
<lastmod>2026-11-23</lastmod>
|
|
12
|
+
<changefreq>weekly</changefreq>
|
|
13
|
+
<priority>0.8</priority>
|
|
14
|
+
</url>
|
|
15
|
+
</urlset>
|