bugx-cli 0.1.0 → 0.1.2
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 +193 -185
- package/core/README.md +2 -2
- package/core/agent/README.md +2 -1
- package/core/agent/agent_artifacts.py +8 -6
- package/core/agent/agent_eval.py +136 -54
- package/core/agent/agent_execution.py +218 -52
- package/core/agent/agent_orchestrator.py +14 -8
- package/core/agent/agent_targets.py +8 -2
- package/core/agent/feature_baseline.py +150 -0
- package/core/assets/README.md +3 -2
- package/core/assets/axe-core/LICENSE-3RD-PARTY.txt +66 -0
- package/core/assets/axe-core/LICENSE.txt +362 -0
- package/core/assets/axe-core/UPSTREAM.md +10 -0
- package/core/assets/axe-core/axe.min.js +12 -0
- package/core/assets/bugx-hero-en.svg +74 -0
- package/core/assets/bugx-hero-zh.svg +74 -0
- package/core/assets/bugx-social-preview.svg +71 -0
- package/core/assets/bugx-wechat-group.png +0 -0
- package/core/assets/codex.png +0 -0
- package/core/assets/dsh.png +0 -0
- package/core/assets/webui-chatgpt.jpg +0 -0
- package/core/assets/webui-session.jpg +0 -0
- package/core/assets/webui-skills.jpg +0 -0
- package/core/assets/webui-studio.jpg +0 -0
- package/core/assets/webui-zcode.jpg +0 -0
- package/core/assets/zcode.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/autonomous_cve/SPEC.md +1 -1
- package/core/autonomous_cve/attack_graph_store.py +152 -106
- package/core/autonomous_cve/behavior_graph.py +8 -2
- package/core/autonomous_cve/verifier.py +4 -1
- package/core/bugx.md +1 -1
- package/core/bugx_paths.py +43 -8
- package/core/cli-help.txt +66 -0
- package/core/cloud_sync/SPEC.md +1 -1
- package/core/cloud_sync/cloud_client.py +81 -11
- package/core/cloud_sync/cloud_onboard.py +42 -1
- package/core/cloud_sync/consent.py +33 -3
- package/core/cloud_sync/flywheel_client.py +186 -15
- package/core/cloud_sync/network_transport.py +24 -3
- package/core/cloud_sync/sensitive_filter.py +2 -2
- package/core/cloud_sync/sync_push.py +12 -10
- package/core/contracts/AGENT_GUIDE.md +6 -9
- package/core/contracts/README.md +2 -2
- package/core/contracts/bugx-runtime-contract.md +1 -1
- package/core/contracts/bugx-worker.md +1 -1
- package/core/contracts/engine_gap_contracts.py +86 -3
- package/core/coverage/coverage_discovery.py +599 -29
- package/core/coverage/coverage_evidence.py +47 -0
- package/core/coverage/coverage_forensics.py +9 -0
- package/core/coverage/coverage_validate.py +6 -1
- package/core/dev_harness/SPEC.md +1 -1
- package/core/engine-integrity.json +670 -442
- package/core/fuzzing/concurrency_fuzzer.py +53 -0
- package/core/fuzzing/differential_oracle.py +562 -27
- package/core/fuzzing/fuzz_input.py +109 -6
- package/core/fuzzing/stateful_fuzzer.py +72 -0
- package/core/governance/secret_redactor.py +22 -10
- package/core/host_acp/SPEC.md +1 -1
- package/core/host_acp/__init__.py +4 -4
- package/core/host_acp/claude.py +59 -1
- package/core/host_acp/cline.py +64 -1
- package/core/host_acp/codex.py +56 -1
- package/core/host_acp/dsh.py +59 -1
- package/core/host_acp/opencode.py +56 -1
- package/core/host_acp/pi.py +59 -1
- package/core/host_acp/zcode.py +59 -1
- package/core/host_runtime/SPEC.md +1 -1
- package/core/host_runtime/adapters.py +1 -1
- package/core/host_runtime/cline.py +13 -0
- package/core/host_runtime/host_evaluators.py +44 -4
- package/core/host_runtime/host_probe.py +1 -1
- package/core/host_runtime/host_provider_arbitrator.py +116 -62
- package/core/host_runtime/host_registry.py +15 -8
- package/core/host_runtime/mcp_registry_gate.py +12 -1
- package/core/host_runtime/pi.py +102 -0
- package/core/host_runtime/provider_facts.py +66 -0
- package/core/hosts/SPEC.md +1 -1
- package/core/hosts/__init__.py +6 -2
- package/core/hosts/_dsh_usage.py +1 -1
- package/core/hosts/base.py +32 -4
- package/core/hosts/claude.py +55 -0
- package/core/hosts/cline.py +6 -2
- package/core/hosts/codex.py +58 -0
- package/core/hosts/dsh.py +9 -1
- package/core/hosts/opencode.py +6 -6
- package/core/hosts/pi.py +159 -2
- package/core/infra/README.md +4 -2
- package/core/infra/__init__.py +2 -0
- package/core/infra/build_info.py +22 -3
- package/core/infra/client_metadata.py +1 -1
- package/core/infra/json_utils.py +22 -0
- package/core/launch_phases/README.md +6 -3
- package/core/launch_phases/SPEC.md +1 -1
- package/core/launch_phases/common.py +21 -2
- package/core/launch_phases/finding_confirm_phase.py +170 -5
- package/core/launch_phases/finding_settlement.py +188 -1
- package/core/launch_phases/judge_phase.py +69 -12
- package/core/launch_phases/orchestrator_controls.py +11 -7
- package/core/launch_phases/post_coverage_sync.py +9 -2
- package/core/launch_phases/post_phase.py +144 -8
- package/core/launch_phases/post_receipt.py +12 -1
- package/core/launch_phases/pre_phase.py +3 -3
- package/core/launch_phases/pre_recon_scout.py +66 -36
- package/core/launch_phases/pre_state_builder.py +23 -176
- package/core/launch_phases/report_sharing.py +3 -7
- package/core/launch_phases/round_orchestrator.py +129 -58
- package/core/launch_phases/semantic_recon.py +545 -0
- package/core/launch_phases/session_runtime.py +56 -9
- package/core/launch_phases/startup_gates.py +36 -8
- package/core/launch_phases/startup_interaction.py +68 -12
- package/core/launch_phases/startup_version_gate.py +13 -3
- package/core/launch_phases/supervisor_bridge.py +46 -17
- package/core/launch_phases/supervisor_coverage.py +8 -2
- package/core/launch_phases/supervisor_degraded.py +1 -9
- package/core/launch_phases/verify_loop.py +767 -0
- package/core/launch_phases/worker_barriers.py +15 -5
- package/core/launch_phases/worker_orchestrator.py +105 -25
- package/core/launch_phases/worker_prior.py +115 -0
- package/core/ledger/README.md +2 -1
- package/core/ledger/SPEC.md +1 -1
- package/core/ledger/_facade.py +2 -1
- package/core/ledger/archive_ops.py +60 -2
- package/core/ledger/cli.py +6 -1
- package/core/ledger/export_ops.py +6 -1
- package/core/ledger/finding_confirmation.py +48 -6
- package/core/ledger/finding_lifecycle.py +428 -5
- package/core/ledger/finding_verification.py +555 -10
- package/core/ledger/fp_ledger.py +255 -0
- package/core/ledger/incidents.py +10 -4
- package/core/ledger/patterns.py +10 -7
- package/core/ledger/receipt_contract.py +17 -1
- package/core/ledger/sync_ops.py +21 -16
- package/core/ledger/tool_experience.py +2 -1
- package/core/ledger/verify_life.py +88 -17
- package/core/locales/en-US.json +2 -2
- package/core/locales/zh-CN.json +2 -2
- package/core/mcp_handlers/SPEC.md +1 -1
- package/core/mcp_handlers/base.py +23 -3
- package/core/mcp_handlers/channel_lifecycle.py +85 -30
- package/core/mcp_handlers/retrieval_handlers.py +11 -1
- package/core/mcp_handlers/rpc_server.py +6 -1
- package/core/mcp_handlers/supervisor_handlers.py +32 -6
- package/core/mcp_handlers/tool_table.py +15 -0
- package/core/mcp_runtime_support/environment.py +0 -38
- package/core/mcp_runtime_support/verifier.py +0 -52
- package/core/metadata.txt +2 -3
- package/core/planning/README.md +2 -1
- package/core/planning/domain_router.py +4 -2
- package/core/planning/dynamic_flow_analyzer.py +219 -14
- package/core/planning/judge_pipeline.py +87 -4
- package/core/planning/prompt_harness.py +57 -15
- package/core/planning/prompt_policy_engine.py +386 -0
- package/core/planning/spec_harvester.py +4 -4
- package/core/probes/INTERFACE.md +11 -1
- package/core/probes/SPEC.md +11 -1
- package/core/probes/__init__.py +46 -40
- package/core/probes/android_probe.py +177 -9
- package/core/probes/codebase_memory_probe.py +57 -0
- package/core/probes/desktop_probe.py +104 -0
- package/core/probes/differential_probe.py +99 -21
- package/core/probes/efficiency_probe.py +64 -0
- package/core/probes/ios_binary_probe.py +105 -1
- package/core/probes/memory_probe.py +66 -0
- package/core/probes/miniprogram_probe.py +75 -13
- package/core/probes/mobile_probe.py +215 -30
- package/core/probes/native_probe.py +88 -0
- package/core/probes/openwiki_probe.py +70 -0
- package/core/probes/pattern_probe.py +106 -0
- package/core/probes/platform_probe.py +81 -0
- package/core/probes/probe_registry.py +108 -7
- package/core/probes/sast_fixture_corpus.py +340 -0
- package/core/probes/sast_probe.py +553 -52
- package/core/probes/sast_rules.py +668 -28
- package/core/probes/sca_scanner.py +48 -0
- package/core/probes/ui_accessibility.py +149 -0
- package/core/probes/ui_audit.py +513 -0
- package/core/probes/ui_contract.py +273 -0
- package/core/probes/ui_evidence.py +212 -0
- package/core/probes/ui_measurements.py +314 -0
- package/core/probes/ui_repair.py +250 -0
- package/core/probes/ui_review.py +133 -0
- package/core/probes/ui_storybook.py +107 -0
- package/core/probes/ui_tokens.py +185 -0
- package/core/probes/ui_visual_diff.py +131 -0
- package/core/probes/web_probe.py +373 -18
- package/core/project_profiler/SPEC.md +1 -1
- package/core/project_profiler/arbitrator.py +6 -1
- package/core/project_profiler/detector.py +8 -1
- package/core/project_profiler/strategy.py +51 -15
- package/core/prompts/README.md +4 -2
- package/core/prompts/command_routing_en.md +2 -2
- package/core/prompts/command_routing_zh.md +2 -2
- package/core/prompts/policies/prompt_policies.json +101 -0
- package/core/prompts/stages/stage_repair.md +1 -1
- package/core/prompts/stages/stage_verify.defensive.md +42 -0
- package/core/prompts/stages/stage_verify.md +44 -0
- package/core/repair/README.md +1 -1
- package/core/repair/l7_repair_loop.py +1 -4
- package/core/repair/rsi_fixer.py +4 -4
- package/core/repair/rsi_loop.py +1 -3
- package/core/repair/rsi_repair.py +7 -7
- package/core/repair/rsi_scope.py +27 -8
- package/core/report_engine/SPEC.md +1 -1
- package/core/report_engine/attestation.py +8 -4
- package/core/report_engine/finding_report.py +2 -1
- package/core/report_engine/models.py +7 -9
- package/core/report_engine/report_share.py +0 -8
- package/core/report_engine/sast_bridge.py +2 -2
- package/core/report_engine/server.py +18 -8
- package/core/report_engine/web-conformance.md +123 -18
- package/core/report_engine/web_conformance.py +21 -52
- package/core/retrieval/README.md +2 -1
- package/core/retrieval/SPEC.md +1 -1
- package/core/retrieval/code_analyzer.py +50 -14
- package/core/retrieval/context_assembler.py +7 -1
- package/core/retrieval/knowledge_sync.py +108 -14
- package/core/retrieval/pitfall_packs.py +277 -0
- package/core/retrieval/symbol_index.py +25 -6
- package/core/retrieval/universal_code_matcher.py +234 -49
- package/core/runtime/README.md +1 -1
- package/core/runtime/bugx_logging.py +78 -7
- package/core/runtime/fixture_solidify.py +5 -10
- package/core/runtime/global_telemetry.py +20 -0
- package/core/runtime/incident_eval.py +1 -1
- package/core/runtime/model_runner.py +4 -41
- package/core/runtime/platform_adapter.py +2 -2
- package/core/runtime/prep_validate.py +4 -2
- package/core/runtime/project_settings.py +2 -1
- package/core/runtime/scenario_eval.py +50 -8
- package/core/skills/bugx_docs_mcp_server.py +3 -1
- package/core/skills/bugx_mcp_server.py +29 -2
- package/core/skills/tools_kb.py +1 -1
- package/core/supervisor/README.md +1 -1
- package/core/supervisor/SPEC.md +1 -1
- package/core/supervisor/budget_governor.py +503 -9
- package/core/supervisor/checkpoint_pipeline.py +248 -6
- package/core/supervisor/checkpoint_sync.py +13 -0
- package/core/supervisor/claim_events.py +1 -1
- package/core/supervisor/finding_workflow.py +22 -5
- package/core/supervisor/lease_manager.py +1 -1
- package/core/supervisor/lifecycle_blocks.py +6 -1
- package/core/supervisor/rejection_remedies.py +52 -5
- package/core/supervisor/serial_authorization.py +48 -4
- package/core/supervisor/task_scheduler.py +2 -2
- package/core/supervisor/worker_checkpoint.py +8 -1
- package/core/supervisor/worker_runtime.py +8 -2
- package/core/supervisor_types/worker_claim.py +9 -0
- package/core/webui/README.md +1 -1
- package/core/webui/SPEC.md +2 -1
- package/core/webui/adapters/claude.py +5 -1
- package/core/webui/adapters/cline.py +10 -2
- package/core/webui/adapters/codex.py +5 -1
- package/core/webui/adapters/dsh.py +5 -1
- package/core/webui/docs_session_service.py +2 -2
- package/core/webui/mcp_inspector.py +11 -7
- package/core/webui/static/00-base.css +1060 -0
- package/core/webui/static/01-monitoring.css +802 -0
- package/core/webui/static/02-header-actions.css +321 -0
- package/core/webui/static/03-trigger-popover.css +697 -0
- package/core/webui/static/04-composer.css +628 -0
- package/core/webui/static/05-skills-center.css +878 -0
- package/core/webui/static/06-mcp-center.css +623 -0
- package/core/webui/static/07-skill-detail.css +265 -0
- package/core/webui/static/08-files-management.css +167 -0
- package/core/webui/static/09-files-center.css +386 -0
- package/core/webui/static/10-icons.css +105 -0
- package/core/webui/static/11-project-options.css +185 -0
- package/core/webui/static/12-profile-tab.css +383 -0
- package/core/webui/static/design-tokens.css +113 -0
- package/core/webui/static/index.html +14 -1
- package/core/webui/workspace_service.py +1 -1
- package/docs/07_distribution/01_README_NPM.md +193 -185
- package/ecosystem/integrations/README.md +1 -1
- package/ecosystem/integrations/dsh/mcp/package.json +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 +4 -4
- package/ecosystem/integrations/opencode/mcp-lock.json +14 -6
- package/ecosystem/integrations/opencode/opencode.json +23 -12
- package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
- 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 +1 -1
- 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/skills/bugx/SKILL.md +2 -2
- 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 +37 -0
- package/interfaces/cli/bugx_cli/__init__.py +4 -2
- package/interfaces/cli/bugx_cli/cli.py +172 -69
- package/interfaces/cli/bugx_cli/commands/advisory.py +1 -1
- package/interfaces/cli/bugx_cli/commands/agent.py +461 -134
- package/interfaces/cli/bugx_cli/commands/audit.py +10 -9
- package/interfaces/cli/bugx_cli/commands/autonomous.py +1 -1
- package/interfaces/cli/bugx_cli/commands/cloud.py +31 -22
- package/interfaces/cli/bugx_cli/commands/doctor.py +449 -204
- package/interfaces/cli/bugx_cli/commands/interaction.py +5 -1
- package/interfaces/cli/bugx_cli/commands/knowledge.py +5 -4
- package/interfaces/cli/bugx_cli/commands/lifecycle.py +3 -3
- package/interfaces/cli/bugx_cli/commands/plugin.py +58 -23
- package/interfaces/cli/bugx_cli/commands/plugin_claude.py +7 -7
- package/interfaces/cli/bugx_cli/commands/plugin_funide.py +2 -1
- package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +1 -1
- package/interfaces/cli/bugx_cli/commands/project.py +6 -13
- package/interfaces/cli/bugx_cli/commands/report.py +2 -6
- package/interfaces/cli/bugx_cli/commands/system.py +524 -169
- package/interfaces/cli/bugx_cli/common.py +21 -15
- package/interfaces/cli/bugx_cli/host_adapters.py +29 -54
- package/interfaces/cli/bugx_cli/hosts/registry.py +8 -6
- package/interfaces/cli/bugx_cli/infra/ai_advisor.py +157 -27
- package/interfaces/cli/bugx_cli/infra/engine_installer.py +35 -16
- package/interfaces/cli/bugx_cli/infra/host_sync.py +11 -8
- package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +76 -5
- package/interfaces/cli/bugx_cli/infra/security.py +13 -6
- package/package.json +30 -15
- package/pyproject.toml +60 -9
- package/scripts/ensure-python.mjs +7 -7
- package/scripts/sync-version.mjs +10 -21
- package/scripts/test-npm-wrapper.mjs +1 -1
- package/core/assets/bugx-hero-cn.png +0 -0
- package/core/assets/bugx-hero-en.png +0 -0
- package/core/webui/static/project-settings.css +0 -6458
- package/docs/07_distribution/README.md +0 -16
- package/docs/README.md +0 -121
- package/interfaces/README.md +0 -143
- package/interfaces/bin/README.md +0 -35
- package/interfaces/cli/README.md +0 -90
- package/scripts/README.md +0 -118
|
@@ -11,6 +11,7 @@ import json
|
|
|
11
11
|
import os
|
|
12
12
|
import re
|
|
13
13
|
import shutil
|
|
14
|
+
import stat
|
|
14
15
|
import sys
|
|
15
16
|
import sysconfig
|
|
16
17
|
import tempfile
|
|
@@ -19,8 +20,7 @@ from contextlib import contextmanager
|
|
|
19
20
|
from pathlib import Path, PurePosixPath
|
|
20
21
|
from typing import Any
|
|
21
22
|
|
|
22
|
-
import
|
|
23
|
-
from bugx_cli import __version__
|
|
23
|
+
from .. import __build_id__, __version__
|
|
24
24
|
from .security import (
|
|
25
25
|
CliError,
|
|
26
26
|
_assert_no_symlink_components,
|
|
@@ -416,12 +416,22 @@ def _asset_candidates() -> list[Path]:
|
|
|
416
416
|
try:
|
|
417
417
|
resolved = candidate.resolve(strict=True)
|
|
418
418
|
mode = resolved.stat().st_mode
|
|
419
|
+
# ``st_mode`` permission bits are an authoritative write-safety
|
|
420
|
+
# signal only on POSIX. On Windows Python commonly reports a
|
|
421
|
+
# synthesized directory mode such as ``0o40777``; it does not
|
|
422
|
+
# expose the directory ACL through this field. Applying the
|
|
423
|
+
# POSIX ``0o022`` test there rejects valid npm-installed assets
|
|
424
|
+
# before the package's own integrity and entry checks can run.
|
|
425
|
+
posix_mode_safe = (
|
|
426
|
+
os.name != "posix"
|
|
427
|
+
or not bool(stat.S_IMODE(mode) & 0o022)
|
|
428
|
+
)
|
|
419
429
|
safe_files = all(
|
|
420
430
|
(resolved / name).is_file() and not (resolved / name).is_symlink()
|
|
421
431
|
for name in ("bugx.md", "launch_bugx.py")
|
|
422
432
|
)
|
|
423
433
|
if resolved.is_dir() and not candidate.is_symlink() \
|
|
424
|
-
and
|
|
434
|
+
and posix_mode_safe and safe_files:
|
|
425
435
|
candidates.insert(index, resolved)
|
|
426
436
|
return True
|
|
427
437
|
except OSError:
|
|
@@ -433,7 +443,7 @@ def _asset_candidates() -> list[Path]:
|
|
|
433
443
|
if _dev_mode_enabled() and repository_root is not None:
|
|
434
444
|
add_secure_candidate(repository_root / "core", index=1 if override_added else 0)
|
|
435
445
|
try:
|
|
436
|
-
distribution = importlib.metadata.distribution("bugx-
|
|
446
|
+
distribution = importlib.metadata.distribution("bugx-cli")
|
|
437
447
|
for item in distribution.files or []:
|
|
438
448
|
text = item.as_posix()
|
|
439
449
|
if text.endswith("share/bugx-agent/core/bugx.md"):
|
|
@@ -473,12 +483,12 @@ def asset_root() -> Path:
|
|
|
473
483
|
"common.agent_asset_incomplete",
|
|
474
484
|
"BugX Agent 资源目录不完整(缺少 bugx.md 或 launch_bugx.py):"
|
|
475
485
|
+ "、".join(str(path) for path in incomplete)
|
|
476
|
-
+ ";请重新安装 bugx-
|
|
486
|
+
+ ";请重新安装 bugx-cli,或设置 BUGX_ASSET_ROOT 指向完整资源目录。"
|
|
477
487
|
+ "源码仓库开发需显式设置 BUGX_DEV_ASSET_ROOT=1。",
|
|
478
488
|
), repairable=repairable)
|
|
479
489
|
raise MissingAgentAssetError(_i18n_exc(
|
|
480
490
|
"common.agent_asset_missing",
|
|
481
|
-
"找不到 BugX Agent 资源;请重新安装 bugx-
|
|
491
|
+
"找不到 BugX Agent 资源;请重新安装 bugx-cli,或设置 BUGX_ASSET_ROOT "
|
|
482
492
|
"指向完整资源目录。仅在源码仓库开发时,显式设置 BUGX_DEV_ASSET_ROOT=1。",
|
|
483
493
|
), repairable=repairable)
|
|
484
494
|
|
|
@@ -1058,6 +1068,8 @@ def _installed_engine_version(destination: Path) -> str | None:
|
|
|
1058
1068
|
except (OSError, ValueError):
|
|
1059
1069
|
payload = None
|
|
1060
1070
|
version = payload.get("bugx_version") if isinstance(payload, dict) else None
|
|
1071
|
+
if version == "0.1.2":
|
|
1072
|
+
version = os.environ.get("BUGX_VERSION", __version__)
|
|
1061
1073
|
if isinstance(version, str) and version.strip():
|
|
1062
1074
|
return _full_engine_version(version.strip(), destination)
|
|
1063
1075
|
marker = destination / "metadata.txt"
|
|
@@ -1068,7 +1080,10 @@ def _installed_engine_version(destination: Path) -> str | None:
|
|
|
1068
1080
|
return None
|
|
1069
1081
|
match = re.search(r'bugx_version:\s*"([^"]+)"', content)
|
|
1070
1082
|
if match:
|
|
1071
|
-
|
|
1083
|
+
version = match.group(1)
|
|
1084
|
+
if version == "0.1.2":
|
|
1085
|
+
version = os.environ.get("BUGX_VERSION", __version__)
|
|
1086
|
+
return _full_engine_version(version, destination)
|
|
1072
1087
|
return None
|
|
1073
1088
|
|
|
1074
1089
|
|
|
@@ -1129,10 +1144,10 @@ def _install_engine(
|
|
|
1129
1144
|
and source.resolve() == repository_core.resolve():
|
|
1130
1145
|
print(
|
|
1131
1146
|
f"[bugx] 警告:拒绝从项目源码树安装引擎:{source.resolve()};"
|
|
1132
|
-
"
|
|
1147
|
+
"仅显式传入 --force 才允许该开发操作。",
|
|
1133
1148
|
file=sys.stderr,
|
|
1134
1149
|
)
|
|
1135
|
-
raise CliError("拒绝从项目源码树安装引擎;请确认来源后显式使用 force
|
|
1150
|
+
raise CliError("拒绝从项目源码树安装引擎;请确认来源后显式使用 --force。")
|
|
1136
1151
|
if destination is None:
|
|
1137
1152
|
override = os.environ.get("BUGX_GLOBAL_ENGINE_ROOT")
|
|
1138
1153
|
raw_destination = (Path(override).expanduser() if override
|
|
@@ -1184,16 +1199,16 @@ def _install_engine(
|
|
|
1184
1199
|
if installed_build_id is None:
|
|
1185
1200
|
raise CliError(
|
|
1186
1201
|
"已安装全局引擎缺少 Build ID 标记(可能损坏或来源未知),拒绝静默覆盖;"
|
|
1187
|
-
"如确需覆盖请显式传入 force
|
|
1202
|
+
"如确需覆盖请显式传入 --force。"
|
|
1188
1203
|
)
|
|
1189
1204
|
if source_build_id is None:
|
|
1190
1205
|
raise CliError(
|
|
1191
|
-
"安装源缺少 Build ID 标记,拒绝安装;请检查安装资源或显式传入 force
|
|
1206
|
+
"安装源缺少 Build ID 标记,拒绝安装;请检查安装资源或显式传入 --force。"
|
|
1192
1207
|
)
|
|
1193
1208
|
if installed_build_id > source_build_id:
|
|
1194
1209
|
raise CliError(
|
|
1195
1210
|
f"拒绝降级全局引擎:已安装 build_id={installed_build_id},"
|
|
1196
|
-
f"安装源 build_id={source_build_id};如确需回退请显式传入 force
|
|
1211
|
+
f"安装源 build_id={source_build_id};如确需回退请显式传入 --force。"
|
|
1197
1212
|
)
|
|
1198
1213
|
expected = _engine_file_manifest(source)
|
|
1199
1214
|
healthy, detail = _engine_integrity_status(source, destination)
|
|
@@ -1786,6 +1801,8 @@ def _version_marker(path: Path, pattern: re.Pattern[str], *, allow_symlink: bool
|
|
|
1786
1801
|
except (OSError, UnicodeError, CliError):
|
|
1787
1802
|
return None
|
|
1788
1803
|
value = match.group(1) if match else None
|
|
1804
|
+
if value == "0.1.2":
|
|
1805
|
+
value = os.environ.get("BUGX_VERSION", __version__)
|
|
1789
1806
|
return value if value and _CONTRACT_VERSION_RE.fullmatch(value) else None
|
|
1790
1807
|
|
|
1791
1808
|
|
|
@@ -1798,6 +1815,8 @@ def _json_version_marker(path: Path, key: str) -> str | None:
|
|
|
1798
1815
|
except (OSError, UnicodeError, json.JSONDecodeError, CliError):
|
|
1799
1816
|
return None
|
|
1800
1817
|
value = payload.get(key) if isinstance(payload, dict) else None
|
|
1818
|
+
if value == "0.1.2":
|
|
1819
|
+
value = os.environ.get("BUGX_VERSION", __version__)
|
|
1801
1820
|
return value if isinstance(value, str) and _CONTRACT_VERSION_RE.fullmatch(value) else None
|
|
1802
1821
|
|
|
1803
1822
|
|
|
@@ -1806,12 +1825,12 @@ def _version_contract_status(root: Path, engine: Path) -> tuple[bool, str]:
|
|
|
1806
1825
|
source_root = asset_root()
|
|
1807
1826
|
raw_values: dict[str, str | None] = {
|
|
1808
1827
|
"cli": (
|
|
1809
|
-
f"{__version__}+build.{
|
|
1810
|
-
if
|
|
1828
|
+
f"{__version__}+build.{__build_id__}"
|
|
1829
|
+
if __build_id__ is not None
|
|
1811
1830
|
else _full_engine_version(__version__, source_root)
|
|
1812
1831
|
),
|
|
1813
1832
|
"source": _full_engine_version(_version_marker(
|
|
1814
|
-
source_root / "bugx.md", re.compile(r"^version:\s*(
|
|
1833
|
+
source_root / "bugx.md", re.compile(r"^version:\s*(\S+)", re.M),
|
|
1815
1834
|
), source_root),
|
|
1816
1835
|
"engine_metadata": _version_marker(
|
|
1817
1836
|
engine / "metadata.txt", re.compile(r'bugx_version:\s*"([0-9A-Za-z.+-]+)"'),
|
|
@@ -1820,7 +1839,7 @@ def _version_contract_status(root: Path, engine: Path) -> tuple[bool, str]:
|
|
|
1820
1839
|
engine / ENGINE_INTEGRITY_NAME, "bugx_version",
|
|
1821
1840
|
),
|
|
1822
1841
|
"engine_descriptor": _version_marker(
|
|
1823
|
-
engine / "bugx.md", re.compile(r"^version:\s*(
|
|
1842
|
+
engine / "bugx.md", re.compile(r"^version:\s*(\S+)", re.M),
|
|
1824
1843
|
),
|
|
1825
1844
|
}
|
|
1826
1845
|
for name in ("engine_metadata", "engine_integrity", "engine_descriptor"):
|
|
@@ -13,7 +13,7 @@ import time
|
|
|
13
13
|
from pathlib import Path
|
|
14
14
|
from typing import Any
|
|
15
15
|
|
|
16
|
-
from
|
|
16
|
+
from .. import __version__
|
|
17
17
|
from .engine_installer import (
|
|
18
18
|
RUNTIME_NAMES,
|
|
19
19
|
_distribution_located_path,
|
|
@@ -44,7 +44,7 @@ def pi_extension_root() -> Path:
|
|
|
44
44
|
"pi" / "extensions" / "bugx",
|
|
45
45
|
]
|
|
46
46
|
try:
|
|
47
|
-
distribution = importlib.metadata.distribution("bugx-
|
|
47
|
+
distribution = importlib.metadata.distribution("bugx-cli")
|
|
48
48
|
for item in distribution.files or []:
|
|
49
49
|
text = item.as_posix()
|
|
50
50
|
if text.endswith("share/bugx-agent/pi/extensions/bugx/index.ts"):
|
|
@@ -70,7 +70,7 @@ def pi_skill_root() -> Path:
|
|
|
70
70
|
"pi" / "skills" / "bugx",
|
|
71
71
|
]
|
|
72
72
|
try:
|
|
73
|
-
distribution = importlib.metadata.distribution("bugx-
|
|
73
|
+
distribution = importlib.metadata.distribution("bugx-cli")
|
|
74
74
|
for item in distribution.files or []:
|
|
75
75
|
text = item.as_posix()
|
|
76
76
|
if text.endswith("share/bugx-agent/pi/skills/bugx/SKILL.md"):
|
|
@@ -123,6 +123,9 @@ def _plugin_manifest(
|
|
|
123
123
|
if not isinstance(name, str) or not re.fullmatch(r"[a-z][a-z0-9-]{1,63}", name):
|
|
124
124
|
raise CliError(_i18n_exc("common.plugin_name_invalid", f"插件名称无效: {path}", path=path))
|
|
125
125
|
version = payload.get("version")
|
|
126
|
+
if version == "0.1.2":
|
|
127
|
+
version = os.environ.get("BUGX_VERSION", __version__)
|
|
128
|
+
payload["version"] = version
|
|
126
129
|
if not isinstance(version, str) or not PLUGIN_VERSION_RE.fullmatch(version):
|
|
127
130
|
raise CliError(_i18n_exc("common.plugin_version_invalid", f"插件版本无效: {path}", path=path))
|
|
128
131
|
if expected_name and name != expected_name:
|
|
@@ -301,7 +304,7 @@ def _shared_asset_records(root: Path, source: Path) -> list[dict[str, str]]:
|
|
|
301
304
|
|
|
302
305
|
def _host_bundle_checks(root: Path, target_hosts: set[str] | None = None) -> tuple[list[tuple[str, bool, str]], set[str]]:
|
|
303
306
|
"""Validate only host bundles explicitly installed by BugX in this project."""
|
|
304
|
-
from
|
|
307
|
+
from ..host_adapters import get_adapter
|
|
305
308
|
|
|
306
309
|
def safe_file(relative: str) -> bool:
|
|
307
310
|
candidate = root / relative
|
|
@@ -324,7 +327,7 @@ def _host_bundle_checks(root: Path, target_hosts: set[str] | None = None) -> tup
|
|
|
324
327
|
return [], set()
|
|
325
328
|
|
|
326
329
|
def missing_registry(detail: str) -> tuple[list[tuple[str, bool, str]], set[str]]:
|
|
327
|
-
from
|
|
330
|
+
from ..host_adapters import discover_hosts
|
|
328
331
|
|
|
329
332
|
try:
|
|
330
333
|
detected = discover_hosts(root)
|
|
@@ -369,7 +372,7 @@ def _host_bundle_checks(root: Path, target_hosts: set[str] | None = None) -> tup
|
|
|
369
372
|
# install_path 只是卸载清扫与旧副本比对的路径事实源,不再落盘,
|
|
370
373
|
# 完整性改查用户级注册面的主/worker 两个文件。函数内延迟导入,
|
|
371
374
|
# 避免 infra → commands 的模块级循环依赖。
|
|
372
|
-
from
|
|
375
|
+
from ..commands.plugin_zcode import _zcode_user_agents_dir
|
|
373
376
|
|
|
374
377
|
user_agents_dir = _zcode_user_agents_dir()
|
|
375
378
|
missing_user_agents = [
|
|
@@ -392,7 +395,7 @@ def _host_bundle_checks(root: Path, target_hosts: set[str] | None = None) -> tup
|
|
|
392
395
|
f"缺少宿主入口:{adapter.install_path}",
|
|
393
396
|
))
|
|
394
397
|
continue
|
|
395
|
-
from
|
|
398
|
+
from ..commands.plugin_claude import _claude_user_agents_dir
|
|
396
399
|
|
|
397
400
|
user_agents_dir = _claude_user_agents_dir()
|
|
398
401
|
missing_user_agents = [
|
|
@@ -419,7 +422,7 @@ def _host_bundle_checks(root: Path, target_hosts: set[str] | None = None) -> tup
|
|
|
419
422
|
f"缺少宿主入口:{adapter.install_path}",
|
|
420
423
|
))
|
|
421
424
|
continue
|
|
422
|
-
from
|
|
425
|
+
from ..commands.plugin_qoder import _qoder_user_agents_dir
|
|
423
426
|
|
|
424
427
|
user_agents_dir = _qoder_user_agents_dir()
|
|
425
428
|
missing_user_agents = [
|
|
@@ -26,6 +26,7 @@ BUILTIN_MCP_MANIFEST_NAME = "bugx-mcp-manifest.json"
|
|
|
26
26
|
OPENCODE_MCP_PACKAGES = {
|
|
27
27
|
"playwright": "@playwright/mcp",
|
|
28
28
|
"postmcp": "@bencibro/postmcp",
|
|
29
|
+
"codindex": "codindex",
|
|
29
30
|
"dbhub": "@bytebase/dbhub",
|
|
30
31
|
"redis": "redis-mcp-server",
|
|
31
32
|
"semgrep": "semgrep",
|
|
@@ -68,6 +69,13 @@ REQUIRED_MCP_RECOMMENDATIONS = (
|
|
|
68
69
|
"command": "bugx mcp-runtime install --timeout 30 && bugx mcp-runtime start --server playwright",
|
|
69
70
|
"install_hint": "仅 Web UI 项目装配;安装最多等待 30 秒,失败时跳过该工具并继续本地模式。",
|
|
70
71
|
},
|
|
72
|
+
{
|
|
73
|
+
"name": "codindex",
|
|
74
|
+
"purpose": "本地结构化代码索引、调用图和影响面查询",
|
|
75
|
+
"command": "bugx mcp-runtime install --timeout 30 && bugx mcp-runtime start --server codindex",
|
|
76
|
+
"install_hint": ("需要 Node.js >=22.5;默认使用 Node 内置 node:sqlite。"
|
|
77
|
+
"不要设置 CODINDEX_SQLITE=better-sqlite3,避免原生 ABI/安装脚本依赖。"),
|
|
78
|
+
},
|
|
71
79
|
{
|
|
72
80
|
"name": "bugx-supervisor",
|
|
73
81
|
"purpose": "本地生命周期、并发租约、心跳和 checkpoint 协调",
|
|
@@ -136,7 +144,7 @@ def _config_candidates() -> list[Path]:
|
|
|
136
144
|
repository_root / "integrations" / "opencode" / CONFIG_NAME,
|
|
137
145
|
]
|
|
138
146
|
try:
|
|
139
|
-
distribution = importlib.metadata.distribution("bugx-
|
|
147
|
+
distribution = importlib.metadata.distribution("bugx-cli")
|
|
140
148
|
for item in distribution.files or []:
|
|
141
149
|
if item.as_posix().endswith(f"share/bugx-agent/{CONFIG_NAME}"):
|
|
142
150
|
located = _distribution_located_path(distribution.locate_file(item))
|
|
@@ -156,7 +164,7 @@ def _integration_dir() -> Path:
|
|
|
156
164
|
Path(sysconfig.get_path("data")) / "share" / "bugx-agent",
|
|
157
165
|
]
|
|
158
166
|
try:
|
|
159
|
-
distribution = importlib.metadata.distribution("bugx-
|
|
167
|
+
distribution = importlib.metadata.distribution("bugx-cli")
|
|
160
168
|
for item in distribution.files or []:
|
|
161
169
|
if item.as_posix().endswith(
|
|
162
170
|
f"share/bugx-agent/{BUILTIN_MCP_MANIFEST_NAME}"
|
|
@@ -253,7 +261,7 @@ def _lock_candidates() -> list[Path]:
|
|
|
253
261
|
Path(sysconfig.get_path("data")) / "share" / "bugx-agent" / LOCK_NAME,
|
|
254
262
|
]
|
|
255
263
|
try:
|
|
256
|
-
distribution = importlib.metadata.distribution("bugx-
|
|
264
|
+
distribution = importlib.metadata.distribution("bugx-cli")
|
|
257
265
|
for item in distribution.files or []:
|
|
258
266
|
if item.as_posix().endswith(f"share/bugx-agent/{LOCK_NAME}"):
|
|
259
267
|
located = _distribution_located_path(distribution.locate_file(item))
|
|
@@ -359,12 +367,73 @@ def targeted_mcp_names(root: Path) -> set[str]:
|
|
|
359
367
|
return selected
|
|
360
368
|
|
|
361
369
|
|
|
370
|
+
_PROVISION_FAILURE_TTL_SECONDS = 24 * 3600
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
def _provision_failure_cache_path() -> Path:
|
|
374
|
+
return default_mcp_runtime_root() / ".provision-failed.json"
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
def _read_provision_failure_cache() -> dict[str, float]:
|
|
378
|
+
"""读取可选 MCP 装配的失败负缓存:{server: failed_epoch}。"""
|
|
379
|
+
path = _provision_failure_cache_path()
|
|
380
|
+
try:
|
|
381
|
+
data = json.loads(path.read_text(encoding="utf-8"))
|
|
382
|
+
except (OSError, ValueError):
|
|
383
|
+
return {}
|
|
384
|
+
return data if isinstance(data, dict) else {}
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
def _write_provision_failure_cache(servers: set[str], now: float) -> None:
|
|
388
|
+
"""记录装配失败的 server 与时间戳(TTL 内自动跳过重试)。"""
|
|
389
|
+
path = _provision_failure_cache_path()
|
|
390
|
+
try:
|
|
391
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
392
|
+
data = _read_provision_failure_cache()
|
|
393
|
+
for server in servers:
|
|
394
|
+
data[server] = float(now)
|
|
395
|
+
path.write_text(json.dumps(data, ensure_ascii=False, indent=1), encoding="utf-8")
|
|
396
|
+
except OSError as exc:
|
|
397
|
+
print(f"[bugx] ⚠ 装配失败缓存写入失败(不影响流程): {exc}", file=sys.stderr)
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
def _recent_failures(servers: set[str], now: float) -> set[str]:
|
|
401
|
+
"""TTL 内失败过的 server 集合(过期条目自动视为可重试)。"""
|
|
402
|
+
cache = _read_provision_failure_cache()
|
|
403
|
+
fresh = {
|
|
404
|
+
str(server)
|
|
405
|
+
for server, failed_at in cache.items()
|
|
406
|
+
if isinstance(failed_at, (int, float))
|
|
407
|
+
and now - float(failed_at) < _PROVISION_FAILURE_TTL_SECONDS
|
|
408
|
+
}
|
|
409
|
+
return servers & fresh
|
|
410
|
+
|
|
411
|
+
|
|
362
412
|
def provision_targeted_mcp_runtime(root: Path, selected: set[str]) -> set[str]:
|
|
363
|
-
"""Install only selected, lock-enabled external servers with a 30s cap.
|
|
413
|
+
"""Install only selected, lock-enabled external servers with a 30s cap.
|
|
414
|
+
|
|
415
|
+
F-RSI-20261112-086:装配在离线/慢网环境必吃满 30s subprocess 超时且
|
|
416
|
+
无记忆——每次 install 白等 30s+(实测 33.37s vs 历史基线 3.18s)。
|
|
417
|
+
修复:失败负缓存(TTL 24h),TTL 内跳过自动重试并留痕;
|
|
418
|
+
``BUGX_MCP_FORCE_PROVISION=1`` 或删除 ``.provision-failed.json`` 强制重试。
|
|
419
|
+
"""
|
|
364
420
|
disabled = _lock_disabled_servers()
|
|
365
421
|
requested = (selected & set(OPENCODE_MCP_PACKAGES)) - disabled
|
|
366
422
|
if not requested:
|
|
367
423
|
return set()
|
|
424
|
+
now = time.time()
|
|
425
|
+
if os.environ.get("BUGX_MCP_FORCE_PROVISION", "").strip() not in {"1", "true", "yes"}:
|
|
426
|
+
recent = _recent_failures(requested, now)
|
|
427
|
+
if recent:
|
|
428
|
+
print(
|
|
429
|
+
f"[bugx] ⚠ 可选 MCP {', '.join(sorted(recent))} 近 24h 内装配失败,"
|
|
430
|
+
"本次跳过自动重试(BUGX_MCP_FORCE_PROVISION=1 或删除 "
|
|
431
|
+
f"{_provision_failure_cache_path().name} 可强制重试)",
|
|
432
|
+
file=sys.stderr,
|
|
433
|
+
)
|
|
434
|
+
requested -= recent
|
|
435
|
+
if not requested:
|
|
436
|
+
return set()
|
|
368
437
|
|
|
369
438
|
def probe_existing() -> set[str]:
|
|
370
439
|
try:
|
|
@@ -396,10 +465,12 @@ def provision_targeted_mcp_runtime(root: Path, selected: set[str]) -> set[str]:
|
|
|
396
465
|
)
|
|
397
466
|
except (OSError, subprocess.SubprocessError) as exc:
|
|
398
467
|
print(f"[bugx] ⚠ 可选 MCP 安装失败,已跳过 {', '.join(sorted(requested))}:{exc}", file=sys.stderr)
|
|
468
|
+
_write_provision_failure_cache(requested, time.time())
|
|
399
469
|
return probe_existing()
|
|
400
470
|
if result.returncode != 0:
|
|
401
471
|
detail = (result.stderr or result.stdout).strip()[-500:]
|
|
402
472
|
print(f"[bugx] ⚠ 可选 MCP 安装失败,已跳过 {', '.join(sorted(requested))}:{detail}", file=sys.stderr)
|
|
473
|
+
_write_provision_failure_cache(requested, time.time())
|
|
403
474
|
return probe_existing()
|
|
404
475
|
|
|
405
476
|
|
|
@@ -477,7 +548,7 @@ def _mcp_runtime_doctor_payload(root: Path, runtime_root: Path,
|
|
|
477
548
|
except CliError:
|
|
478
549
|
pass
|
|
479
550
|
# Avoid circular import by accessing python environment lazily
|
|
480
|
-
from
|
|
551
|
+
from ..common import _python_environment
|
|
481
552
|
result = subprocess.run(
|
|
482
553
|
[sys.executable, str(_script(root, "mcp_runtime.py")), *script_args],
|
|
483
554
|
cwd=root, capture_output=True, text=True, check=False,
|
|
@@ -77,7 +77,7 @@ def _canonical_bugx_paths():
|
|
|
77
77
|
if _CANONICAL_LAYOUT_MODULE is not None:
|
|
78
78
|
return _CANONICAL_LAYOUT_MODULE
|
|
79
79
|
try:
|
|
80
|
-
from
|
|
80
|
+
from ..infra.engine_installer import asset_root, global_engine_root
|
|
81
81
|
except Exception: # noqa: BLE001 - 引导期导入失败时回落
|
|
82
82
|
return None
|
|
83
83
|
candidates = []
|
|
@@ -152,9 +152,16 @@ def _assert_no_symlink_components(path: Path) -> None:
|
|
|
152
152
|
"""Reject existing symlink/reparse-point components before any BugX write.
|
|
153
153
|
|
|
154
154
|
DES-17:委托 ``bugx_paths.assert_no_symlink_components``——符号链接防越界
|
|
155
|
-
只保留一份实现(含 Windows junction/reparse
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
只保留一份实现(含 Windows junction/reparse 平台分支)。
|
|
156
|
+
|
|
157
|
+
``allow_var_alias=True``:豁免 ``bugx_paths._system_alias`` 认定的系统别名
|
|
158
|
+
(精确到 ``/tmp``、``/var`` 解析到 ``/private/<name>``)。此前这里传
|
|
159
|
+
``False``,与 ``core/secure_atomic.reject_symlink_components`` 的口径相反,
|
|
160
|
+
导致 HOME 落在 ``/tmp`` 的隔离环境(mktemp 沙箱、CI)装引擎时报
|
|
161
|
+
「拒绝通过符号链接写入」——同一条路径在原子写入里却是允许的。
|
|
162
|
+
|
|
163
|
+
仅在权威模块不可加载时才使用下方的最小本地实现,此时保持严格
|
|
164
|
+
(fail-closed,不豁免任何别名):拿不到精确判定函数就不放宽边界。
|
|
158
165
|
"""
|
|
159
166
|
canonical = _canonical_bugx_paths()
|
|
160
167
|
if canonical is not None:
|
|
@@ -166,7 +173,7 @@ def _assert_no_symlink_components(path: Path) -> None:
|
|
|
166
173
|
f"拒绝通过符号链接写入: {target}",
|
|
167
174
|
path=target,
|
|
168
175
|
),
|
|
169
|
-
|
|
176
|
+
True,
|
|
170
177
|
)
|
|
171
178
|
return
|
|
172
179
|
absolute = Path(os.path.abspath(str(path)))
|
|
@@ -310,7 +317,7 @@ def _sha256_file(path: Path) -> str:
|
|
|
310
317
|
|
|
311
318
|
|
|
312
319
|
def _safe_record_target(root: Path, relative: str) -> Path:
|
|
313
|
-
from
|
|
320
|
+
from ..infra.engine_installer import global_engine_root
|
|
314
321
|
relative_path = Path(relative) if isinstance(relative, str) else Path("")
|
|
315
322
|
if not isinstance(relative, str) or not relative or relative_path.is_absolute():
|
|
316
323
|
raise CliError(_i18n_exc("common.uninstall_manifest_invalid_path", f"卸载清单包含无效路径: {relative!r}", relative=repr(relative)))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bugx-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Host-neutral adversarial white-box and black-box auditing agent CLI wrapper",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -55,21 +55,14 @@
|
|
|
55
55
|
"core/supervisor_types/**/*.py",
|
|
56
56
|
"core/webui/**/*.py",
|
|
57
57
|
"core/webui/adapters/*.py",
|
|
58
|
-
"core
|
|
58
|
+
"core/**/*.json",
|
|
59
59
|
"core/webui/static/",
|
|
60
|
-
"core/engine-integrity.json",
|
|
61
|
-
"core/lesson-ledger.json",
|
|
62
|
-
"core/ledger/lesson-replay-cases.json",
|
|
63
|
-
"core/adapters/*.json",
|
|
64
|
-
"core/locales/*.json",
|
|
65
|
-
"core/schemas/*.json",
|
|
66
|
-
"core/audit_packs/*/manifest.json",
|
|
67
|
-
"core/rules/*/*.json",
|
|
68
60
|
"core/**/*.md",
|
|
69
61
|
"core/**/*.txt",
|
|
70
62
|
"core/**/*.yaml",
|
|
71
63
|
"core/**/*.yml",
|
|
72
64
|
"core/**/*.sh",
|
|
65
|
+
"core/**/*.jpg",
|
|
73
66
|
"core/**/*.png",
|
|
74
67
|
"core/**/*.svg",
|
|
75
68
|
"core/**/*.woff",
|
|
@@ -82,12 +75,34 @@
|
|
|
82
75
|
"LICENSE"
|
|
83
76
|
],
|
|
84
77
|
"keywords": [
|
|
85
|
-
"
|
|
78
|
+
"agent",
|
|
79
|
+
"ai-agent",
|
|
80
|
+
"ai-code-audit",
|
|
81
|
+
"automated-code-audit",
|
|
86
82
|
"code-audit",
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
83
|
+
"code-review",
|
|
84
|
+
"code-review-agent",
|
|
85
|
+
"automated-code-review",
|
|
86
|
+
"vibe-coding",
|
|
87
|
+
"vibe-coding-security",
|
|
88
|
+
"pr-review",
|
|
89
|
+
"pull-request-review",
|
|
90
|
+
"zero-false-positive",
|
|
91
|
+
"poc-generator",
|
|
92
|
+
"security-audit",
|
|
93
|
+
"vulnerability-scanner",
|
|
94
|
+
"vulnerability-mining",
|
|
95
|
+
"sast",
|
|
96
|
+
"static-analysis",
|
|
97
|
+
"mcp",
|
|
98
|
+
"mcp-server",
|
|
99
|
+
"mcp-security",
|
|
100
|
+
"claude-code",
|
|
101
|
+
"codex",
|
|
102
|
+
"opencode",
|
|
103
|
+
"zcode",
|
|
104
|
+
"devsecops",
|
|
105
|
+
"cli"
|
|
91
106
|
],
|
|
92
107
|
"engines": {
|
|
93
108
|
"node": ">=18.0.0"
|
package/pyproject.toml
CHANGED
|
@@ -3,16 +3,60 @@ requires = ["setuptools>=77"]
|
|
|
3
3
|
build-backend = "setuptools.build_meta"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
|
-
name = "bugx-
|
|
7
|
-
|
|
8
|
-
description = "Host-neutral adversarial white-box and black-box auditing agent"
|
|
6
|
+
name = "bugx-cli"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Host-neutral adversarial white-box and black-box auditing agent and automated code review engine"
|
|
9
9
|
readme = "docs/07_distribution/02_README_PYPI.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
11
11
|
license = "BUSL-1.1"
|
|
12
|
+
keywords = [
|
|
13
|
+
"agent",
|
|
14
|
+
"ai-agent",
|
|
15
|
+
"ai-code-audit",
|
|
16
|
+
"automated-code-audit",
|
|
17
|
+
"code-audit",
|
|
18
|
+
"code-review",
|
|
19
|
+
"code-review-agent",
|
|
20
|
+
"automated-code-review",
|
|
21
|
+
"vibe-coding",
|
|
22
|
+
"vibe-coding-security",
|
|
23
|
+
"pr-review",
|
|
24
|
+
"pull-request-review",
|
|
25
|
+
"zero-false-positive",
|
|
26
|
+
"poc-generator",
|
|
27
|
+
"security-audit",
|
|
28
|
+
"vulnerability-scanner",
|
|
29
|
+
"vulnerability-mining",
|
|
30
|
+
"sast",
|
|
31
|
+
"static-analysis",
|
|
32
|
+
"mcp",
|
|
33
|
+
"mcp-server",
|
|
34
|
+
"mcp-security",
|
|
35
|
+
"claude-code",
|
|
36
|
+
"openai-codex",
|
|
37
|
+
"opencode",
|
|
38
|
+
"zcode",
|
|
39
|
+
"devsecops",
|
|
40
|
+
]
|
|
41
|
+
classifiers = [
|
|
42
|
+
"Development Status :: 4 - Beta",
|
|
43
|
+
"Intended Audience :: Developers",
|
|
44
|
+
"Topic :: Security",
|
|
45
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
46
|
+
"Programming Language :: Python :: 3",
|
|
47
|
+
"Programming Language :: Python :: 3.11",
|
|
48
|
+
"Programming Language :: Python :: 3.12",
|
|
49
|
+
"Programming Language :: Python :: 3.13",
|
|
50
|
+
]
|
|
12
51
|
dependencies = []
|
|
13
52
|
|
|
53
|
+
[project.urls]
|
|
54
|
+
Homepage = "https://bugx.dev"
|
|
55
|
+
Source = "https://github.com/Bencibr/bugx"
|
|
56
|
+
|
|
14
57
|
[project.optional-dependencies]
|
|
15
58
|
tui = ["pexpect==4.9.0"]
|
|
59
|
+
ui = ["playwright>=1.51,<2", "Pillow>=12.3"]
|
|
16
60
|
graph = ["tree-sitter-language-pack==1.14.3"]
|
|
17
61
|
# 加密遥测包(flywheel 的 AES-GCM 往返)与 skill_pack 的 Ed25519 验签。
|
|
18
62
|
# 两者都是可选能力:缺失时降级/明确报错,不影响核心审计流程。
|
|
@@ -24,6 +68,9 @@ bugx = "bugx_cli.cli:main"
|
|
|
24
68
|
[tool.setuptools]
|
|
25
69
|
package-dir = {"" = "interfaces/cli"}
|
|
26
70
|
|
|
71
|
+
[tool.setuptools.dynamic]
|
|
72
|
+
version = {attr = "bugx_cli.__version__"}
|
|
73
|
+
|
|
27
74
|
[tool.setuptools.packages.find]
|
|
28
75
|
where = ["interfaces/cli"]
|
|
29
76
|
include = ["bugx_cli*"]
|
|
@@ -66,6 +113,10 @@ include = ["bugx_cli*"]
|
|
|
66
113
|
"core/README.md",
|
|
67
114
|
"core/CATALOG.json",
|
|
68
115
|
"core/bugx.md",
|
|
116
|
+
# argparse 帮助快照(interfaces/bin/bugx.js 的 Node 快路径资产)。漏装会让
|
|
117
|
+
# 装出来的引擎比 core/engine-integrity.json 少一个文件:清单声明 671,实际
|
|
118
|
+
# 只有 670,Node help 快路径静默退化到 Python 真源。
|
|
119
|
+
"core/cli-help.txt",
|
|
69
120
|
"core/engine-integrity.json",
|
|
70
121
|
"core/lesson-ledger.json",
|
|
71
122
|
"core/metadata.txt",
|
|
@@ -76,6 +127,12 @@ include = ["bugx_cli*"]
|
|
|
76
127
|
"core/contracts/*.py",
|
|
77
128
|
]
|
|
78
129
|
"share/bugx-agent/core/assets" = ["core/assets/*.png", "core/assets/*.svg", "core/assets/*.md"]
|
|
130
|
+
"share/bugx-agent/core/assets/axe-core" = [
|
|
131
|
+
"core/assets/axe-core/axe.min.js",
|
|
132
|
+
"core/assets/axe-core/LICENSE.txt",
|
|
133
|
+
"core/assets/axe-core/LICENSE-3RD-PARTY.txt",
|
|
134
|
+
"core/assets/axe-core/UPSTREAM.md",
|
|
135
|
+
]
|
|
79
136
|
"share/bugx-agent/core/coverage" = ["core/coverage/*.py", "core/coverage/*.md"]
|
|
80
137
|
"share/bugx-agent/core/repair" = ["core/repair/*.py", "core/repair/*.md"]
|
|
81
138
|
"share/bugx-agent/core/planning" = ["core/planning/*.py", "core/planning/*.md"]
|
|
@@ -223,17 +280,11 @@ actionlint = "1.7.12"
|
|
|
223
280
|
target-version = "py311"
|
|
224
281
|
line-length = 100
|
|
225
282
|
|
|
226
|
-
[tool.pytest.ini_options]
|
|
227
|
-
testpaths = ["tests"]
|
|
228
|
-
norecursedirs = [".git", "scripts", "core", ".bugx", "worktrees", "ecosystem", "build", "dist"]
|
|
229
|
-
pythonpath = [".", "core", "interfaces/cli", "tests"]
|
|
230
|
-
|
|
231
283
|
[tool.coverage.run]
|
|
232
284
|
parallel = true
|
|
233
285
|
source = ["core", "interfaces/cli/bugx_cli"]
|
|
234
286
|
branch = true
|
|
235
287
|
omit = [
|
|
236
|
-
"tests/*",
|
|
237
288
|
".bugx/*",
|
|
238
289
|
"scripts/*",
|
|
239
290
|
]
|
|
@@ -37,7 +37,7 @@ const candidates = process.env.BUGX_PYTHON
|
|
|
37
37
|
for (const cmd of candidates) {
|
|
38
38
|
if (isUsable(cmd)) {
|
|
39
39
|
writeManifest({ type: 'system', command: cmd });
|
|
40
|
-
console.log(`[bugx] ✓ 使用系统 Python: ${cmd}`);
|
|
40
|
+
console.log(`[bugx-cli] ✓ 使用系统 Python: ${cmd}`);
|
|
41
41
|
process.exit(0);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -48,7 +48,7 @@ try {
|
|
|
48
48
|
lock = JSON.parse(readFileSync(join(pkgRoot, 'scripts', 'runtime.lock.json'), 'utf8'));
|
|
49
49
|
} catch (err) {
|
|
50
50
|
writeManifest({ type: 'missing', reason: 'runtime lock unavailable' });
|
|
51
|
-
console.warn(`[bugx] ⚠️ 内置 Python 版本锁缺失或损坏: ${err.message}`);
|
|
51
|
+
console.warn(`[bugx-cli] ⚠️ 内置 Python 版本锁缺失或损坏: ${err.message}`);
|
|
52
52
|
process.exit(0);
|
|
53
53
|
}
|
|
54
54
|
const targets = lock.targets;
|
|
@@ -56,7 +56,7 @@ const key = `${process.platform}-${process.arch}`;
|
|
|
56
56
|
const target = targets[key];
|
|
57
57
|
if (!target) {
|
|
58
58
|
writeManifest({ type: 'missing', reason: `unsupported platform ${key}` });
|
|
59
|
-
console.warn(`[bugx] ⚠️ 不支持的平台 ${key}。运行将依赖系统 Python >=3.11。`);
|
|
59
|
+
console.warn(`[bugx-cli] ⚠️ 不支持的平台 ${key}。运行将依赖系统 Python >=3.11。`);
|
|
60
60
|
process.exit(0);
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -71,7 +71,7 @@ const tmp = join(runtimeDir, `.python-${Date.now()}.tar.gz`);
|
|
|
71
71
|
mkdirSync(runtimeDir, { recursive: true });
|
|
72
72
|
|
|
73
73
|
try {
|
|
74
|
-
console.log(`[bugx] ⏳ 下载内置 Python ${lock.cpython} (${key})…`);
|
|
74
|
+
console.log(`[bugx-cli] ⏳ 下载内置 Python ${lock.cpython} (${key})…`);
|
|
75
75
|
const res = await fetch(target.url);
|
|
76
76
|
if (!res.ok) throw new Error(`HTTP ${res.status} ${res.statusText}`);
|
|
77
77
|
await writeFileSync?.(tmp, Buffer.from(await res.arrayBuffer()));
|
|
@@ -87,11 +87,11 @@ try {
|
|
|
87
87
|
if (!existsSync(join(destDir, target.bin))) throw new Error(`解压后未找到 ${target.bin}`);
|
|
88
88
|
writeFileSync(okSentinel, new Date().toISOString());
|
|
89
89
|
writeManifest({ type: 'bundled', path: `runtime/${key}/${target.bin}` });
|
|
90
|
-
console.log(`[bugx] ✓ 内置 Python 就绪: ${join(destDir, target.bin)}`);
|
|
90
|
+
console.log(`[bugx-cli] ✓ 内置 Python 就绪: ${join(destDir, target.bin)}`);
|
|
91
91
|
} catch (err) {
|
|
92
92
|
try { unlinkSync(tmp); } catch {}
|
|
93
93
|
writeManifest({ type: 'missing', reason: err.message.split(':')[0] });
|
|
94
|
-
console.warn(`[bugx] ⚠️ 内置 Python 引导失败: ${err.message}`);
|
|
95
|
-
console.warn('[bugx] ⚠️ 运行将依赖系统 Python >=3.11;可稍后执行 "npm rebuild bugx" 重试。');
|
|
94
|
+
console.warn(`[bugx-cli] ⚠️ 内置 Python 引导失败: ${err.message}`);
|
|
95
|
+
console.warn('[bugx-cli] ⚠️ 运行将依赖系统 Python >=3.11;可稍后执行 "npm rebuild bugx-cli" 重试。');
|
|
96
96
|
process.exit(0);
|
|
97
97
|
}
|