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.
Files changed (131) hide show
  1. package/README.md +36 -35
  2. package/core/README.md +1 -1
  3. package/core/agent/agent_orchestrator.py +3 -0
  4. package/core/agent/agent_workspace.py +14 -2
  5. package/core/assets/README.md +3 -2
  6. package/core/assets/bugx-social-preview.svg +71 -0
  7. package/core/assets/bugx-wechat-group.png +0 -0
  8. package/core/assets/twitter_promo_art.jpg +0 -0
  9. package/core/assets/twitter_promo_card.svg +166 -0
  10. package/core/assets/twitter_promo_clean.jpg +0 -0
  11. package/core/assets/twitter_terminal_real.png +0 -0
  12. package/core/audit_packs/README.md +2 -0
  13. package/core/audit_packs/pitfalls/auth_crypto.json +64 -0
  14. package/core/audit_packs/pitfalls/file_ssrf_cmd.json +64 -0
  15. package/core/audit_packs/pitfalls/go_backend.json +66 -0
  16. package/core/audit_packs/pitfalls/java_spring.json +64 -0
  17. package/core/audit_packs/pitfalls/js_ts_web.json +67 -0
  18. package/core/audit_packs/pitfalls/python_web.json +82 -0
  19. package/core/bugx.md +2 -2
  20. package/core/bugx_paths.py +2 -2
  21. package/core/cli-help.txt +1 -1
  22. package/core/cloud_sync/cloud_client.py +56 -5
  23. package/core/cloud_sync/consent.py +33 -3
  24. package/core/cloud_sync/flywheel_client.py +186 -24
  25. package/core/contracts/README.md +1 -1
  26. package/core/contracts/bugx-opencode.md +1 -1
  27. package/core/contracts/bugx-runtime-contract.md +1 -1
  28. package/core/contracts/bugx-worker.md +1 -1
  29. package/core/engine-integrity.json +191 -95
  30. package/core/host_acp/kimi.py +175 -0
  31. package/core/host_acp/minimax.py +28 -0
  32. package/core/host_runtime/host_registry.py +23 -3
  33. package/core/hosts/dsh.py +1 -1
  34. package/core/hosts/kimi.py +293 -0
  35. package/core/hosts/minimax.py +248 -0
  36. package/core/hosts/zcode.py +5 -0
  37. package/core/infra/README.md +1 -1
  38. package/core/infra/build_info.py +30 -5
  39. package/core/launch_phases/README.md +6 -3
  40. package/core/launch_phases/finding_confirm_phase.py +168 -7
  41. package/core/launch_phases/post_phase.py +5 -5
  42. package/core/launch_phases/pre_recon_scout.py +13 -0
  43. package/core/launch_phases/report_sharing.py +3 -7
  44. package/core/launch_phases/round_orchestrator.py +114 -26
  45. package/core/launch_phases/semantic_recon.py +545 -0
  46. package/core/launch_phases/startup_version_gate.py +6 -2
  47. package/core/launch_phases/supervisor_bridge.py +14 -23
  48. package/core/launch_phases/verify_loop.py +767 -0
  49. package/core/launch_phases/worker_prior.py +115 -0
  50. package/core/ledger/README.md +2 -1
  51. package/core/ledger/finding_verification.py +511 -2
  52. package/core/ledger/fp_ledger.py +255 -0
  53. package/core/metadata.txt +2 -2
  54. package/core/planning/README.md +2 -1
  55. package/core/planning/prompt_harness.py +50 -10
  56. package/core/planning/prompt_policy_engine.py +386 -0
  57. package/core/prompts/README.md +4 -2
  58. package/core/prompts/policies/prompt_policies.json +101 -0
  59. package/core/prompts/stages/stage_verify.defensive.md +42 -0
  60. package/core/prompts/stages/stage_verify.md +44 -0
  61. package/core/report_engine/report_share.py +0 -8
  62. package/core/retrieval/README.md +2 -1
  63. package/core/retrieval/pitfall_packs.py +277 -0
  64. package/core/runtime/README.md +1 -1
  65. package/core/runtime/global_telemetry.py +20 -0
  66. package/core/runtime/scenario_eval.py +1 -1
  67. package/core/runtime/setup_ui_env.py +4 -7
  68. package/core/supervisor/README.md +1 -1
  69. package/core/supervisor/cli.py +2 -2
  70. package/core/webui/mcp_inspector.py +6 -0
  71. package/core/webui/static/index.html +51 -3
  72. package/core/webui/static/manifest.webmanifest +1 -1
  73. package/core/webui/static/project-settings.js +18 -3
  74. package/core/webui/static/robots.txt +36 -0
  75. package/core/webui/static/sitemap.xml +15 -0
  76. package/docs/07_distribution/01_README_NPM.md +36 -35
  77. package/ecosystem/integrations/cline/skills/bugx/SKILL.md +1 -1
  78. package/ecosystem/integrations/dsh/agents/bugx.md +1 -1
  79. package/ecosystem/integrations/dsh/dsh-patch.yml +2 -2
  80. package/ecosystem/integrations/dsh/mcp/package.json +1 -1
  81. package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +1 -1
  82. package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +1 -1
  83. package/ecosystem/integrations/dsh/ui/package.json +1 -1
  84. package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +1 -1
  85. package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
  86. package/ecosystem/integrations/pi/skills/bugx/SKILL.md +1 -1
  87. package/ecosystem/integrations/qoder/connector-meta.json +9 -9
  88. package/ecosystem/integrations/workbuddy/connector-meta.json +9 -9
  89. package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +2 -2
  90. package/ecosystem/plugins/bugx/.claude-plugin/marketplace.json +2 -2
  91. package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +2 -2
  92. package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +4 -4
  93. package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +2 -2
  94. package/ecosystem/plugins/bugx/agents/bugx-worker.md +1 -1
  95. package/ecosystem/plugins/bugx/agents/bugx.md +1 -1
  96. package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +3 -3
  97. package/ecosystem/plugins/bugx/skills/bugx-claude/SKILL.md +1 -1
  98. package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +1 -1
  99. package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +1 -1
  100. package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +1 -1
  101. package/interfaces/bin/bugx.js +9 -7
  102. package/interfaces/cli/bugx_cli/__init__.py +2 -2
  103. package/interfaces/cli/bugx_cli/cli.py +178 -67
  104. package/interfaces/cli/bugx_cli/commands/agent.py +313 -127
  105. package/interfaces/cli/bugx_cli/commands/audit.py +8 -7
  106. package/interfaces/cli/bugx_cli/commands/cloud.py +27 -19
  107. package/interfaces/cli/bugx_cli/commands/doctor.py +18 -0
  108. package/interfaces/cli/bugx_cli/commands/knowledge.py +3 -4
  109. package/interfaces/cli/bugx_cli/commands/lifecycle.py +54 -47
  110. package/interfaces/cli/bugx_cli/commands/plugin.py +9 -9
  111. package/interfaces/cli/bugx_cli/commands/plugin_claude.py +27 -13
  112. package/interfaces/cli/bugx_cli/commands/plugin_kimi.py +348 -0
  113. package/interfaces/cli/bugx_cli/commands/plugin_minimax.py +322 -0
  114. package/interfaces/cli/bugx_cli/commands/plugin_qoder.py +3 -4
  115. package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +4 -5
  116. package/interfaces/cli/bugx_cli/commands/project.py +6 -13
  117. package/interfaces/cli/bugx_cli/commands/system.py +577 -162
  118. package/interfaces/cli/bugx_cli/common.py +102 -15
  119. package/interfaces/cli/bugx_cli/host_adapters.py +150 -4
  120. package/interfaces/cli/bugx_cli/hosts/registry.py +4 -2
  121. package/interfaces/cli/bugx_cli/hosts/template_engine.py +10 -9
  122. package/interfaces/cli/bugx_cli/infra/engine_installer.py +21 -10
  123. package/interfaces/cli/bugx_cli/infra/host_sync.py +1 -1
  124. package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +2 -2
  125. package/package.json +54 -16
  126. package/pyproject.toml +64 -1
  127. package/scripts/sync-version.mjs +1 -1
  128. package/skills/README.md +25 -0
  129. package/skills/platform/bugx-user/SKILL.md +92 -0
  130. package/core/assets/bugx-hero-cn.png +0 -0
  131. package/core/assets/bugx-hero-en.png +0 -0
@@ -170,8 +170,8 @@ def replay_share_pending(*, force: bool = False) -> None:
170
170
 
171
171
  ``submit`` 是自动重放授权;``local`` 的 share_pending 是**事后**通道——
172
172
  旧实现对 ``local`` 硬短路,导致队列永不补偿(2026-11-09 复盘 4.3-2)。
173
- 现在 ``--replay-share-pending`` 显式授权(``force=True``)即可在 ``local``
174
- 下重放;``none`` 仍是硬禁止(本轮不参与共享),只有显式把策略改为
173
+ 现在使用 ``--replay-share-pending`` 显式授权即可在 ``local`` 下重放;
174
+ ``none`` 仍是硬禁止(本轮不参与共享),只有显式把策略改为
175
175
  ``local``/``submit`` 才能清账。
176
176
  """
177
177
  report_policy = _runtime_report_policy({})
@@ -312,7 +312,7 @@ def _maybe_enqueue_flywheel(runtime: dict, lifecycle: dict) -> None:
312
312
  pass
313
313
 
314
314
 
315
- def maybe_share_lifecycle(runtime: dict, lifecycle: dict, share: str | None) -> str:
315
+ def maybe_share_lifecycle(runtime: dict, lifecycle: dict) -> str:
316
316
  """按已持久化 ``report_policy`` 处理封存报告,不再通过旧 flag 交互。
317
317
 
318
318
  DOC-236 C6:若 L1 已采集并持久化 `report_policy`,则**按它执行且不再交互**
@@ -320,10 +320,6 @@ def maybe_share_lifecycle(runtime: dict, lifecycle: dict, share: str | None) ->
320
320
  `submit` 直接无交互提交(私有)。
321
321
  """
322
322
  report_policy = _runtime_report_policy(runtime)
323
- if share is not None:
324
- raise RuntimeError(
325
- "旧的 share/--no-share 参数已移除;请在 L1 使用 report_policy=none|local|submit"
326
- )
327
323
  if report_policy == "none":
328
324
  print(" (report_policy=none:本轮不参与结论共享与知识飞轮)")
329
325
  return "completed"
@@ -3,6 +3,7 @@
3
3
 
4
4
  from __future__ import annotations
5
5
 
6
+ import argparse
6
7
  import contextlib
7
8
  import difflib
8
9
  import hashlib
@@ -455,6 +456,66 @@ _KNOWN_CMDS = frozenset({
455
456
  "coverage",
456
457
  })
457
458
 
459
+ # The manual dispatchers use these argument shapes before opening a project.
460
+ # Other actions delegate argument parsing to their owning module.
461
+ _MANUAL_OPTIONS = {
462
+ "abort": ((), ("reason",)),
463
+ "bootstrap-coverage": (("confirm", "fresh-coverage"), ()),
464
+ "heartbeat": ((), ()),
465
+ "pause": ((), ()),
466
+ "polling": ((), ()),
467
+ "prompt": ((), ("stage",)),
468
+ "resume": ((), ()),
469
+ "workers": (
470
+ ("execute", "dry-run", "brief"),
471
+ ("count", "strategy", "provider", "model", "executable", "host",
472
+ "subagent-type", "max-workers", "stagger-seconds"),
473
+ ),
474
+ }
475
+ _STARTUP_OPTIONS = (
476
+ ("allow-serial", "approve-strategy", "autonomous", "bootstrap-coverage",
477
+ "ignore-global-budget", "json", "refresh-probes", "replay-share-pending"),
478
+ ("cloud-sync", "commit-policy", "fix-mode", "host", "lesson-category", "lesson-query",
479
+ "life-kind", "max-round-wall-seconds", "polling", "profile", "report-policy",
480
+ "review-mode", "serial-reason", "session-recovery", "startup-action",
481
+ "startup-interaction", "strategy-plan", "tooling-choice"),
482
+ )
483
+
484
+
485
+ def _manual_action_parser(command: str) -> argparse.ArgumentParser | None:
486
+ parser = argparse.ArgumentParser(prog=f"bugx engine {command}", allow_abbrev=False)
487
+ if command == "post":
488
+ parser.epilog = "结论共享由启动时设置的 --report-policy 控制。"
489
+ modes = parser.add_mutually_exclusive_group()
490
+ modes.add_argument("--dry-run", action="store_true", help="只评估结算快照")
491
+ modes.add_argument("--final", action="store_true", help="最终结算")
492
+ parser.add_argument("--allow-incomplete", action="store_true")
493
+ parser.add_argument("--allow-serial", action="store_true")
494
+ elif command in {"status", "control"}:
495
+ if command == "control":
496
+ parser.add_argument("action", nargs="?", default="status",
497
+ choices=("pause", "resume", "abort", "status"))
498
+ parser.add_argument("--reason")
499
+ parser.add_argument("--json", action="store_true")
500
+ else:
501
+ if command in {"pre", "audit"}:
502
+ switches, values = _STARTUP_OPTIONS
503
+ # [BEGIN DEV_ONLY: DEV_MODE_CLI_VALIDATION]
504
+ parser.add_argument("--dev", action="store_true")
505
+ # [END DEV_ONLY: DEV_MODE_CLI_VALIDATION]
506
+ elif command in _MANUAL_OPTIONS:
507
+ switches, values = _MANUAL_OPTIONS[command]
508
+ else:
509
+ return None
510
+ for name in switches:
511
+ parser.add_argument(f"--{name}", action="store_true")
512
+ number_types = {"count": int, "max-workers": int, "stagger-seconds": float} if command == "workers" else {}
513
+ for name in values:
514
+ parser.add_argument(f"--{name}", type=number_types.get(name, str))
515
+ if command == "polling":
516
+ parser.add_argument("policy", nargs="?", choices=("status", "auto", "manual"))
517
+ return parser
518
+
458
519
 
459
520
  def _reject_legacy_share_policy(argv: list[str]) -> int | None:
460
521
  """Reject the removed pre flag before any project/runtime side effect."""
@@ -480,8 +541,47 @@ def main(argv: list[str]) -> int:
480
541
  if legacy_share_policy is not None:
481
542
  return legacy_share_policy
482
543
  command = values[1] if len(values) > 1 else "status"
483
- if command != "post" or "--dry-run" in values[2:]:
484
- return _main_impl(values)
544
+ tail = values[2:]
545
+ if command in {"help", "--help", "-h"}:
546
+ if len(tail) > 1 or (tail and tail[0] not in _KNOWN_CMDS):
547
+ print("[launch_bugx] 未知帮助主题。", file=sys.stderr)
548
+ return 2
549
+ if tail and tail[0] not in {"help", "--help", "-h"}:
550
+ return main([values[0], tail[0], "--help"])
551
+ return _print_help()
552
+ if tail == ["help"]:
553
+ tail = ["--help"]
554
+ values[2:] = tail
555
+ options = None
556
+ if command in {"pre", "audit"} and "--allow-degraded" in tail and not {"-h", "--help"}.intersection(tail):
557
+ print("[launch_bugx] --allow-degraded 已移除。请修复缺失的安装或配置。", file=sys.stderr)
558
+ return 2
559
+ parser = _manual_action_parser(command)
560
+ if parser is not None:
561
+ if command in {"pre", "audit"} and {"-h", "--help"}.intersection(tail):
562
+ return _print_help()
563
+ removed_share = any(t.split("=", 1)[0] in {"--share", "--no-share"} for t in tail)
564
+ if command == "post" and removed_share and not {"-h", "--help"}.intersection(tail):
565
+ print("[launch_bugx] post 的共享选项已移除。请使用启动时的 --report-policy。", file=sys.stderr)
566
+ return 2
567
+ try:
568
+ options = parser.parse_args(tail)
569
+ except SystemExit as exc:
570
+ return int(exc.code)
571
+ if command == "control":
572
+ if options.reason is not None and options.action != "abort":
573
+ print("[launch_bugx] --reason 仅用于 control abort。", file=sys.stderr)
574
+ return 2
575
+ if options.json and options.action != "status":
576
+ print("[launch_bugx] --json 仅用于 control status。", file=sys.stderr)
577
+ return 2
578
+ if command == "post" and options.dry_run:
579
+ if options.allow_incomplete or options.allow_serial:
580
+ print("[launch_bugx] --dry-run 不接受结算授权选项。", file=sys.stderr)
581
+ return 2
582
+ return _post_dry_run_cli()
583
+ if command != "post":
584
+ return _main_impl(values, _options=options)
485
585
  from core.launch_phases.post_observability import (
486
586
  attempt_scope, current_attempt, log_attempt_finished,
487
587
  record_unhandled_exception,
@@ -489,7 +589,7 @@ def main(argv: list[str]) -> int:
489
589
  with attempt_scope("dispatcher") as attempt:
490
590
  try:
491
591
  result = _main_impl(
492
- values, _post_attempt_token=attempt.attempt_token,
592
+ values, _post_attempt_token=attempt.attempt_token, _options=options,
493
593
  )
494
594
  except BaseException as exc:
495
595
  exit_code = 130 if isinstance(exc, KeyboardInterrupt) else 1
@@ -511,6 +611,7 @@ def main(argv: list[str]) -> int:
511
611
 
512
612
  def _main_impl(
513
613
  argv: list[str], *, _post_attempt_token: object | None = None,
614
+ _options: argparse.Namespace | None = None,
514
615
  ) -> int:
515
616
  if argv and (argv[0] in _KNOWN_CMDS or argv[0].startswith("-")):
516
617
  argv = ["launch_bugx.py"] + list(argv)
@@ -519,7 +620,7 @@ def _main_impl(
519
620
  if legacy_share_policy is not None:
520
621
  return legacy_share_policy
521
622
  _HELP_TOKENS = {"help", "--help", "-h"}
522
- if cmd in _HELP_TOKENS or any(token in _HELP_TOKENS for token in argv[2:]):
623
+ if cmd in _HELP_TOKENS or any(token in {"--help", "-h"} for token in argv[2:]):
523
624
  # 帮助契约要求三种写法都只读:`pre help` / `pre -h` 若不在这里截住,
524
625
  # 会落进真实 pre 相位并写启动态,违反文档承诺。
525
626
  return _print_help()
@@ -530,21 +631,13 @@ def _main_impl(
530
631
  from core.runtime import project_init
531
632
 
532
633
  if project_init.is_uninitialized_project(resolve_project_root()):
533
- return status(as_json="--json" in argv[2:])
634
+ return status(as_json=_options.json)
534
635
  except (OSError, ValueError, RuntimeError) as exc:
535
- if "--json" in argv[2:]:
636
+ if _options.json:
536
637
  print(json.dumps({"status": "BLOCKED", "reason": str(exc)}, ensure_ascii=False))
537
638
  else:
538
639
  print(f"[launch_bugx] ✗ 项目状态检查失败:{exc}")
539
640
  return 1
540
- if cmd in {"pre", "audit"} and "--allow-degraded" in argv[2:]:
541
- # DOC-236 C1(A4):降级放行已废除。守卫必须位于**所有** pre/audit 出口
542
- # 之前——放在尾部 dispatch 会被前置硬门禁(交互/版本/云/策略门禁)提前
543
- # 返回绕过,从而变成"静默忽略"而不是"显式拒绝"。
544
- print("[launch_bugx] ✗ --allow-degraded 已废除(DOC-236 C1 不允许降级):"
545
- "请先自愈安装/配置;确无自动安装器的专有工具,"
546
- "在 .bugx/config.json 的 tooling_exemptions 中显式豁免。")
547
- return 1
548
641
  # DOC-236 C5:只做轻量布局/config/fingerprint 准备;宿主、交互、Git、
549
642
  # 版本与云门禁全部通过后才进入完整画像/探针/coverage pipeline。
550
643
  # DOC-174 的 pending ticket 只做一次廉价恢复,不重新启动昂贵初始化。
@@ -587,8 +680,6 @@ def _main_impl(
587
680
  except (OSError, ValueError, RuntimeError, subprocess.SubprocessError) as exc:
588
681
  print(f"[launch_bugx] ✗ 项目初始化/续做失败:{exc}")
589
682
  return 1
590
- if cmd == "post" and "--dry-run" in argv[2:]:
591
- return _post_dry_run_cli()
592
683
  logger = None
593
684
  if cmd == "post":
594
685
  # Set up diagnostics before layout/version/runtime-path gates can reject.
@@ -824,8 +915,6 @@ def _main_impl(
824
915
  try:
825
916
  result: int
826
917
  if cmd == "post":
827
- _share = "share" if "--share" in argv[2:] else (
828
- "no-share" if "--no-share" in argv[2:] else None)
829
918
  post_started = time.monotonic()
830
919
  phase_status = "failed"
831
920
  try:
@@ -837,9 +926,9 @@ def _main_impl(
837
926
  ) as tracker:
838
927
  try:
839
928
  result = post(
840
- final="--final" in argv[2:], share=_share,
841
- allow_incomplete="--allow-incomplete" in argv[2:],
842
- allow_serial="--allow-serial" in argv[2:],
929
+ final=_options.final,
930
+ allow_incomplete=_options.allow_incomplete,
931
+ allow_serial=_options.allow_serial,
843
932
  _post_attempt_token=_post_attempt_token,
844
933
  )
845
934
  phase_status = "ok" if result == 0 else "failed"
@@ -874,7 +963,7 @@ def _main_impl(
874
963
  duration_seconds=round(phase_duration, 3),
875
964
  )
876
965
  elif cmd == "status":
877
- result = status(as_json="--json" in argv[2:])
966
+ result = status(as_json=_options.json)
878
967
  elif cmd == "polling":
879
968
  value = argv[2] if len(argv) > 2 else None
880
969
  result = polling(value)
@@ -892,7 +981,6 @@ def _main_impl(
892
981
  fresh_coverage="--fresh-coverage" in argv[2:],
893
982
  )
894
983
  elif cmd in {"pre", "audit"}:
895
- # `--allow-degraded` 已在 `_main_impl` 入口统一拒绝(A4),此处不再重复判定。
896
984
  pre_args = argv[2:]
897
985
  is_dev = dev_mode_requested
898
986
  strategy_plan_val = None
@@ -941,15 +1029,15 @@ def _main_impl(
941
1029
  host=_option_value(pre_args, "--host"),
942
1030
  )
943
1031
  elif cmd == "control":
944
- sub = argv[2] if len(argv) > 2 else "status"
1032
+ sub = _options.action
945
1033
  if sub == "pause":
946
1034
  result = pause()
947
1035
  elif sub == "resume":
948
1036
  result = resume()
949
1037
  elif sub == "abort":
950
- result = abort(_option_value(argv[3:], "--reason"))
1038
+ result = abort(_options.reason)
951
1039
  else:
952
- result = status(as_json="--json" in argv[2:])
1040
+ result = status(as_json=_options.json)
953
1041
  elif cmd == "findings-confirm":
954
1042
  from core.launch_phases import finding_confirm_phase
955
1043
  result = finding_confirm_phase.main(argv[2:])