bugx-cli 0.1.0 → 0.1.1
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 +190 -186
- 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/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/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/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 +25 -6
- package/core/cloud_sync/cloud_onboard.py +42 -1
- package/core/cloud_sync/flywheel_client.py +16 -7
- 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 +591 -419
- 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 +2 -2
- package/core/launch_phases/SPEC.md +1 -1
- package/core/launch_phases/common.py +21 -2
- package/core/launch_phases/finding_confirm_phase.py +5 -1
- 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 +139 -3
- 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 +53 -36
- package/core/launch_phases/pre_state_builder.py +23 -176
- package/core/launch_phases/round_orchestrator.py +15 -32
- 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 +9 -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/worker_barriers.py +15 -5
- package/core/launch_phases/worker_orchestrator.py +105 -25
- package/core/ledger/README.md +1 -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 +44 -8
- 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 +1 -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 +7 -5
- 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/command_routing_en.md +2 -2
- package/core/prompts/command_routing_zh.md +2 -2
- package/core/prompts/stages/stage_repair.md +1 -1
- 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/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 +1 -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/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/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 +190 -186
- 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 +11 -4
- package/interfaces/cli/bugx_cli/commands/advisory.py +1 -1
- package/interfaces/cli/bugx_cli/commands/agent.py +339 -73
- package/interfaces/cli/bugx_cli/commands/audit.py +2 -2
- package/interfaces/cli/bugx_cli/commands/autonomous.py +1 -1
- package/interfaces/cli/bugx_cli/commands/cloud.py +4 -3
- 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 +2 -0
- package/interfaces/cli/bugx_cli/commands/lifecycle.py +3 -3
- package/interfaces/cli/bugx_cli/commands/plugin.py +55 -20
- 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/report.py +2 -6
- package/interfaces/cli/bugx_cli/commands/system.py +11 -11
- package/interfaces/cli/bugx_cli/common.py +15 -7
- 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 +18 -10
- 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 +2 -1
- package/pyproject.toml +20 -8
- package/scripts/ensure-python.mjs +7 -7
- package/scripts/sync-version.mjs +10 -21
- package/scripts/test-npm-wrapper.mjs +1 -1
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bugx-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1+build.9",
|
|
4
4
|
"description": "Host-neutral adversarial white-box and black-box auditing agent CLI wrapper",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"core/**/*.yaml",
|
|
71
71
|
"core/**/*.yml",
|
|
72
72
|
"core/**/*.sh",
|
|
73
|
+
"core/**/*.jpg",
|
|
73
74
|
"core/**/*.png",
|
|
74
75
|
"core/**/*.svg",
|
|
75
76
|
"core/**/*.woff",
|
package/pyproject.toml
CHANGED
|
@@ -3,16 +3,21 @@ requires = ["setuptools>=77"]
|
|
|
3
3
|
build-backend = "setuptools.build_meta"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
|
-
name = "bugx-
|
|
7
|
-
|
|
6
|
+
name = "bugx-cli"
|
|
7
|
+
dynamic = ["version"]
|
|
8
8
|
description = "Host-neutral adversarial white-box and black-box auditing agent"
|
|
9
9
|
readme = "docs/07_distribution/02_README_PYPI.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
11
11
|
license = "BUSL-1.1"
|
|
12
12
|
dependencies = []
|
|
13
13
|
|
|
14
|
+
[project.urls]
|
|
15
|
+
Homepage = "https://bugx.dev"
|
|
16
|
+
Source = "https://github.com/Bencibr/bugx"
|
|
17
|
+
|
|
14
18
|
[project.optional-dependencies]
|
|
15
19
|
tui = ["pexpect==4.9.0"]
|
|
20
|
+
ui = ["playwright>=1.51,<2", "Pillow>=12.3"]
|
|
16
21
|
graph = ["tree-sitter-language-pack==1.14.3"]
|
|
17
22
|
# 加密遥测包(flywheel 的 AES-GCM 往返)与 skill_pack 的 Ed25519 验签。
|
|
18
23
|
# 两者都是可选能力:缺失时降级/明确报错,不影响核心审计流程。
|
|
@@ -24,6 +29,9 @@ bugx = "bugx_cli.cli:main"
|
|
|
24
29
|
[tool.setuptools]
|
|
25
30
|
package-dir = {"" = "interfaces/cli"}
|
|
26
31
|
|
|
32
|
+
[tool.setuptools.dynamic]
|
|
33
|
+
version = {attr = "bugx_cli.__version__"}
|
|
34
|
+
|
|
27
35
|
[tool.setuptools.packages.find]
|
|
28
36
|
where = ["interfaces/cli"]
|
|
29
37
|
include = ["bugx_cli*"]
|
|
@@ -66,6 +74,10 @@ include = ["bugx_cli*"]
|
|
|
66
74
|
"core/README.md",
|
|
67
75
|
"core/CATALOG.json",
|
|
68
76
|
"core/bugx.md",
|
|
77
|
+
# argparse 帮助快照(interfaces/bin/bugx.js 的 Node 快路径资产)。漏装会让
|
|
78
|
+
# 装出来的引擎比 core/engine-integrity.json 少一个文件:清单声明 671,实际
|
|
79
|
+
# 只有 670,Node help 快路径静默退化到 Python 真源。
|
|
80
|
+
"core/cli-help.txt",
|
|
69
81
|
"core/engine-integrity.json",
|
|
70
82
|
"core/lesson-ledger.json",
|
|
71
83
|
"core/metadata.txt",
|
|
@@ -76,6 +88,12 @@ include = ["bugx_cli*"]
|
|
|
76
88
|
"core/contracts/*.py",
|
|
77
89
|
]
|
|
78
90
|
"share/bugx-agent/core/assets" = ["core/assets/*.png", "core/assets/*.svg", "core/assets/*.md"]
|
|
91
|
+
"share/bugx-agent/core/assets/axe-core" = [
|
|
92
|
+
"core/assets/axe-core/axe.min.js",
|
|
93
|
+
"core/assets/axe-core/LICENSE.txt",
|
|
94
|
+
"core/assets/axe-core/LICENSE-3RD-PARTY.txt",
|
|
95
|
+
"core/assets/axe-core/UPSTREAM.md",
|
|
96
|
+
]
|
|
79
97
|
"share/bugx-agent/core/coverage" = ["core/coverage/*.py", "core/coverage/*.md"]
|
|
80
98
|
"share/bugx-agent/core/repair" = ["core/repair/*.py", "core/repair/*.md"]
|
|
81
99
|
"share/bugx-agent/core/planning" = ["core/planning/*.py", "core/planning/*.md"]
|
|
@@ -223,17 +241,11 @@ actionlint = "1.7.12"
|
|
|
223
241
|
target-version = "py311"
|
|
224
242
|
line-length = 100
|
|
225
243
|
|
|
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
244
|
[tool.coverage.run]
|
|
232
245
|
parallel = true
|
|
233
246
|
source = ["core", "interfaces/cli/bugx_cli"]
|
|
234
247
|
branch = true
|
|
235
248
|
omit = [
|
|
236
|
-
"tests/*",
|
|
237
249
|
".bugx/*",
|
|
238
250
|
"scripts/*",
|
|
239
251
|
]
|
|
@@ -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
|
}
|
package/scripts/sync-version.mjs
CHANGED
|
@@ -1,37 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
//
|
|
2
|
+
// Materialize the npm manifest from BUGX_VERSION for a build tree.
|
|
3
3
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { dirname, join, resolve } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
|
|
7
7
|
const pkgRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const match = pyprojectContent.match(/^version\s*=\s*"([^"]+)"/m);
|
|
12
|
-
if (!match) {
|
|
13
|
-
console.error('[bugx] ✗ 未在 pyproject.toml 中找到 version');
|
|
8
|
+
const version = process.env.BUGX_VERSION?.trim();
|
|
9
|
+
if (!version || !/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(version)) {
|
|
10
|
+
console.error('[bugx] ✗ 必须通过 BUGX_VERSION 提供合法 SemVer');
|
|
14
11
|
process.exit(1);
|
|
15
12
|
}
|
|
16
|
-
const version = match[1];
|
|
17
13
|
|
|
18
|
-
//
|
|
14
|
+
// package.json is a checked-in template; this command materializes it in a
|
|
15
|
+
// temporary/build tree before npm reads the manifest.
|
|
19
16
|
const pkgJsonPath = join(pkgRoot, 'package.json');
|
|
20
17
|
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, 'utf8'));
|
|
18
|
+
if (pkgJson.version === '0.1.1') {
|
|
19
|
+
console.error('[bugx] ✗ 源码 package.json 是模板;请先在临时构建树运行 scripts/render_version.py 或 scripts/package_dist.py');
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
21
22
|
if (pkgJson.version !== version) {
|
|
22
23
|
pkgJson.version = version;
|
|
23
24
|
writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2) + '\n');
|
|
24
25
|
console.log(`[bugx] ✓ 同步 package.json version -> ${version}`);
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
-
// 2. interfaces/cli/bugx_cli/__init__.py
|
|
28
|
-
const initPyPath = join(pkgRoot, 'interfaces', 'cli', 'bugx_cli', '__init__.py');
|
|
29
|
-
const initPyContent = readFileSync(initPyPath, 'utf8');
|
|
30
|
-
const updatedInitPy = initPyContent.replace(
|
|
31
|
-
/__version__\s*=\s*"[^"]+"/,
|
|
32
|
-
`__version__ = "${version}"`,
|
|
33
|
-
);
|
|
34
|
-
if (updatedInitPy !== initPyContent) {
|
|
35
|
-
writeFileSync(initPyPath, updatedInitPy);
|
|
36
|
-
console.log(`[bugx] ✓ 同步 interfaces/cli/bugx_cli/__init__.py __version__ -> ${version}`);
|
|
37
|
-
}
|
|
@@ -60,7 +60,7 @@ try {
|
|
|
60
60
|
assert('1. bin/bugx.js --version 返回 0 代码且输出包含版本号', () => {
|
|
61
61
|
const res = spawnSync('node', [binScript, '--version'], { env: testEnv, encoding: 'utf8' });
|
|
62
62
|
if (res.status !== 0) throw new Error(`Exit code ${res.status}: ${res.stderr}`);
|
|
63
|
-
if (
|
|
63
|
+
if (!/\d+\.\d+\.\d+/.test(res.stdout)) {
|
|
64
64
|
throw new Error(`Unexpected stdout: ${res.stdout}`);
|
|
65
65
|
}
|
|
66
66
|
});
|