bugx-cli 0.1.1__py3-none-any.whl

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 (762) hide show
  1. bugx_cli/__init__.py +6 -0
  2. bugx_cli/cli.py +1685 -0
  3. bugx_cli/commands/__init__.py +1 -0
  4. bugx_cli/commands/advisory.py +94 -0
  5. bugx_cli/commands/agent.py +4210 -0
  6. bugx_cli/commands/audit.py +632 -0
  7. bugx_cli/commands/autonomous.py +260 -0
  8. bugx_cli/commands/cloud.py +1371 -0
  9. bugx_cli/commands/daemon.py +50 -0
  10. bugx_cli/commands/doctor.py +1590 -0
  11. bugx_cli/commands/goal.py +107 -0
  12. bugx_cli/commands/interaction.py +248 -0
  13. bugx_cli/commands/knowledge.py +619 -0
  14. bugx_cli/commands/lifecycle.py +2763 -0
  15. bugx_cli/commands/patch.py +1014 -0
  16. bugx_cli/commands/plugin.py +2749 -0
  17. bugx_cli/commands/plugin_claude.py +1446 -0
  18. bugx_cli/commands/plugin_cline.py +269 -0
  19. bugx_cli/commands/plugin_codex.py +74 -0
  20. bugx_cli/commands/plugin_funide.py +729 -0
  21. bugx_cli/commands/plugin_qoder.py +216 -0
  22. bugx_cli/commands/plugin_zcode.py +710 -0
  23. bugx_cli/commands/project.py +670 -0
  24. bugx_cli/commands/report.py +256 -0
  25. bugx_cli/commands/skill.py +251 -0
  26. bugx_cli/commands/stats.py +133 -0
  27. bugx_cli/commands/system.py +2567 -0
  28. bugx_cli/common.py +906 -0
  29. bugx_cli/host_adapters.py +1892 -0
  30. bugx_cli/hosts/__init__.py +80 -0
  31. bugx_cli/hosts/base.py +99 -0
  32. bugx_cli/hosts/registry.py +573 -0
  33. bugx_cli/hosts/template_engine.py +188 -0
  34. bugx_cli/infra/__init__.py +209 -0
  35. bugx_cli/infra/ai_advisor.py +851 -0
  36. bugx_cli/infra/engine_installer.py +1945 -0
  37. bugx_cli/infra/host_sync.py +548 -0
  38. bugx_cli/infra/mcp_advisor.py +826 -0
  39. bugx_cli/infra/security.py +339 -0
  40. bugx_cli-0.1.1.data/data/share/bugx-agent/bugx-mcp-manifest.json +53 -0
  41. bugx_cli-0.1.1.data/data/share/bugx-agent/core/CATALOG.json +141 -0
  42. bugx_cli-0.1.1.data/data/share/bugx-agent/core/README.md +254 -0
  43. bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/README.md +35 -0
  44. bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/android-interaction.json +81 -0
  45. bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/android.json +24 -0
  46. bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/desktop-macos.json +20 -0
  47. bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/ios-interaction.json +34 -0
  48. bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/ios.json +23 -0
  49. bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/memory-macos.json +24 -0
  50. bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/README.md +51 -0
  51. bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/__init__.py +146 -0
  52. bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_artifacts.py +766 -0
  53. bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_eval.py +1155 -0
  54. bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_execution.py +718 -0
  55. bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_orchestrator.py +1351 -0
  56. bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_targets.py +877 -0
  57. bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_workspace.py +770 -0
  58. bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/feature_baseline.py +150 -0
  59. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/README.md +24 -0
  60. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/LICENSE-3RD-PARTY.txt +66 -0
  61. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/LICENSE.txt +362 -0
  62. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/UPSTREAM.md +10 -0
  63. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/axe.min.js +12 -0
  64. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar-1024.png +0 -0
  65. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar-512.png +0 -0
  66. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar-tight.svg +23 -0
  67. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar.svg +28 -0
  68. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-cn.png +0 -0
  69. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-en.png +0 -0
  70. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-en.svg +74 -0
  71. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-zh.svg +74 -0
  72. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/codex.png +0 -0
  73. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/dsh.png +0 -0
  74. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/project-layout.md +42 -0
  75. bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/zcode.png +0 -0
  76. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/README.md +37 -0
  77. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/manifest.json +94 -0
  78. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/00-scope.md +14 -0
  79. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/10-schema-inventory.md +14 -0
  80. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/20-query-and-integrity.md +14 -0
  81. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/80-evidence-regression.md +14 -0
  82. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/manifest.json +123 -0
  83. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/00-scope.md +15 -0
  84. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/10-process-model.md +14 -0
  85. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/20-package-integrity.md +15 -0
  86. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/30-ui-behavior.md +14 -0
  87. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/80-evidence-regression.md +15 -0
  88. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/memory-testing.md +227 -0
  89. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/manifest.json +155 -0
  90. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/android.md +19 -0
  91. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/h5.md +18 -0
  92. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/ios.md +25 -0
  93. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/miniprogram.md +26 -0
  94. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/webview.md +18 -0
  95. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/00-scope.md +14 -0
  96. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/10-platform-inventory.md +14 -0
  97. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/20-masvs-static.md +20 -0
  98. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/30-component-exposure.md +14 -0
  99. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/40-device-behavior.md +14 -0
  100. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/80-evidence-regression.md +13 -0
  101. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/manifest.json +127 -0
  102. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/00-scope.md +14 -0
  103. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/10-static-white-box.md +14 -0
  104. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/20-memory-concurrency.md +15 -0
  105. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/30-behavior-black-box.md +39 -0
  106. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/80-evidence-regression.md +14 -0
  107. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/platform-testing.md +174 -0
  108. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/manifest.json +191 -0
  109. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/graphql.md +5 -0
  110. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/h5.md +18 -0
  111. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/multi-tenant.md +4 -0
  112. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/oauth.md +4 -0
  113. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/upload.md +4 -0
  114. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/websocket.md +4 -0
  115. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/00-scope.md +13 -0
  116. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/10-discovery.md +13 -0
  117. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/20-auth-session.md +13 -0
  118. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/30-authz-business.md +13 -0
  119. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/40-input-output.md +13 -0
  120. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/50-state-async.md +13 -0
  121. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/60-file-ssrf-deser.md +12 -0
  122. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/70-config-dependency.md +12 -0
  123. bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/80-evidence-regression.md +12 -0
  124. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/INTERFACE.md +61 -0
  125. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/README.md +58 -0
  126. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/SPEC.md +25 -0
  127. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/__init__.py +109 -0
  128. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/attack_graph.py +1096 -0
  129. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/attack_graph_store.py +1868 -0
  130. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/audit_campaign.py +1232 -0
  131. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/behavior_graph.py +465 -0
  132. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/ghsa_advisories.py +174 -0
  133. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/models.py +93 -0
  134. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/mutator.py +87 -0
  135. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/patcher.py +126 -0
  136. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/scout.py +278 -0
  137. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/synthesizer.py +207 -0
  138. bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/verifier.py +103 -0
  139. bugx_cli-0.1.1.data/data/share/bugx-agent/core/bugx.md +1299 -0
  140. bugx_cli-0.1.1.data/data/share/bugx-agent/core/bugx_paths.py +1881 -0
  141. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cli-help.txt +66 -0
  142. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/INTERFACE.md +32 -0
  143. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/README.md +62 -0
  144. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/SPEC.md +25 -0
  145. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/__init__.py +23 -0
  146. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/auto_sync.py +398 -0
  147. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/cloud_client.py +1218 -0
  148. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/cloud_onboard.py +743 -0
  149. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/cloud_schema.py +648 -0
  150. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/consent.py +81 -0
  151. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/device_identity.py +307 -0
  152. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/endpoint_router.py +415 -0
  153. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/flywheel_client.py +769 -0
  154. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/network_transport.py +296 -0
  155. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/onboard_wizard.py +493 -0
  156. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/sensitive_filter.py +285 -0
  157. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/sync_pull.py +695 -0
  158. bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/sync_push.py +723 -0
  159. bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/AGENT_GUIDE.md +359 -0
  160. bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/README.md +34 -0
  161. bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-blackbox.md +541 -0
  162. bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-opencode.md +469 -0
  163. bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-quick.md +44 -0
  164. bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-runtime-contract.md +353 -0
  165. bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-worker.md +470 -0
  166. bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/engine_gap_contracts.py +473 -0
  167. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/README.md +70 -0
  168. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/__init__.py +106 -0
  169. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_ai_review.py +185 -0
  170. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_backfill.py +54 -0
  171. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_bootstrap.py +713 -0
  172. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_business.py +36 -0
  173. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_cli.py +715 -0
  174. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_discovery.py +1429 -0
  175. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_evidence.py +1024 -0
  176. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_forensics.py +124 -0
  177. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_gate.py +277 -0
  178. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_intelligence.py +734 -0
  179. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_manifest.py +396 -0
  180. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_platform.py +77 -0
  181. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_validate.py +241 -0
  182. bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/module_coverage.py +157 -0
  183. bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/INTERFACE.md +20 -0
  184. bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/README.md +21 -0
  185. bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/SPEC.md +25 -0
  186. bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/__init__.py +5 -0
  187. bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/interaction_preset.py +408 -0
  188. bugx_cli-0.1.1.data/data/share/bugx-agent/core/engine-integrity.json +2797 -0
  189. bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/README.md +49 -0
  190. bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/__init__.py +82 -0
  191. bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/concurrency_fuzzer.py +435 -0
  192. bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/differential_oracle.py +1164 -0
  193. bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/fuzz_input.py +1291 -0
  194. bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/stateful_fuzzer.py +404 -0
  195. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/README.md +61 -0
  196. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/__init__.py +130 -0
  197. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/capacity_planner.py +124 -0
  198. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/dependency_lock.py +317 -0
  199. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/goal_governor.py +754 -0
  200. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/guide_budget.py +458 -0
  201. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/lockdown.sh +50 -0
  202. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/readonly_enforcer.py +154 -0
  203. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/runtime_tool_gate.py +373 -0
  204. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/secret_redactor.py +784 -0
  205. bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/token_budget.py +38 -0
  206. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/INTERFACE.md +36 -0
  207. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/README.md +51 -0
  208. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/SPEC.md +25 -0
  209. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/__init__.py +121 -0
  210. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/base.py +111 -0
  211. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/claude.py +99 -0
  212. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/cline.py +298 -0
  213. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/codex.py +300 -0
  214. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/dsh.py +106 -0
  215. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/opencode.py +209 -0
  216. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/pi.py +94 -0
  217. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/zcode.py +99 -0
  218. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/INTERFACE.md +24 -0
  219. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/README.md +62 -0
  220. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/SPEC.md +25 -0
  221. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/__init__.py +21 -0
  222. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/adapters.py +412 -0
  223. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/autonomous_runner.py +1152 -0
  224. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/cline.py +448 -0
  225. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/common.py +103 -0
  226. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/free_models.py +786 -0
  227. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_bootstrap.py +389 -0
  228. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_evaluators.py +761 -0
  229. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_probe.py +41 -0
  230. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_provider_arbitrator.py +831 -0
  231. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_registry.py +662 -0
  232. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_usage.py +127 -0
  233. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/mcp_process_tracker.py +509 -0
  234. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/mcp_registry_gate.py +379 -0
  235. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/pi.py +102 -0
  236. bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/provider_facts.py +66 -0
  237. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/INTERFACE.md +51 -0
  238. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/README.md +67 -0
  239. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/SPEC.md +25 -0
  240. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/__init__.py +140 -0
  241. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_base_usage.py +152 -0
  242. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_codex_usage.py +297 -0
  243. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_dsh_usage.py +184 -0
  244. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_mcp_toml.py +365 -0
  245. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_zcode_usage.py +269 -0
  246. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/base.py +479 -0
  247. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/claude.py +212 -0
  248. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/cline.py +229 -0
  249. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/codex.py +1006 -0
  250. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/dsh.py +526 -0
  251. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/opencode.py +358 -0
  252. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/pi.py +308 -0
  253. bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/zcode.py +219 -0
  254. bugx_cli-0.1.1.data/data/share/bugx-agent/core/i18n.py +252 -0
  255. bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/README.md +41 -0
  256. bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/__init__.py +17 -0
  257. bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/build_info.py +105 -0
  258. bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/client_metadata.py +185 -0
  259. bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/json_utils.py +22 -0
  260. bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/python_runtime.py +540 -0
  261. bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/safe_xml.py +221 -0
  262. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_bugx.py +118 -0
  263. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/INTERFACE.md +31 -0
  264. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/README.md +106 -0
  265. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/SPEC.md +25 -0
  266. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/__init__.py +29 -0
  267. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/candidate_revalidation.py +484 -0
  268. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/common.py +1060 -0
  269. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/finding_confirm_phase.py +391 -0
  270. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/finding_settlement.py +1432 -0
  271. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/findings_adjudication.py +666 -0
  272. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/findings_snapshot.py +357 -0
  273. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/judge_phase.py +848 -0
  274. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/lesson_context.py +536 -0
  275. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/lifecycle_reporter.py +627 -0
  276. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/orchestrator_controls.py +686 -0
  277. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_commit.py +567 -0
  278. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_coverage_sync.py +598 -0
  279. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_dry_run.py +817 -0
  280. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_observability.py +367 -0
  281. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_phase.py +1223 -0
  282. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_receipt.py +373 -0
  283. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_round_lifecycle.py +786 -0
  284. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/pre_phase.py +1029 -0
  285. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/pre_recon_scout.py +879 -0
  286. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/pre_state_builder.py +1133 -0
  287. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/report_sharing.py +414 -0
  288. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/round_orchestrator.py +1116 -0
  289. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/session_runtime.py +1670 -0
  290. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/startup_gates.py +1050 -0
  291. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/startup_interaction.py +1003 -0
  292. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/startup_version_gate.py +879 -0
  293. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/supervisor_bridge.py +1253 -0
  294. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/supervisor_coverage.py +423 -0
  295. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/supervisor_degraded.py +1211 -0
  296. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/worker_barriers.py +424 -0
  297. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/worker_orchestrator.py +1246 -0
  298. bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/worker_prior.py +749 -0
  299. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/INTERFACE.md +35 -0
  300. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/README.md +160 -0
  301. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/SPEC.md +25 -0
  302. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/__init__.py +67 -0
  303. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/_facade.py +227 -0
  304. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/archive_ops.py +630 -0
  305. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/auto_materialization.py +459 -0
  306. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/bug-log.md +22 -0
  307. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/cli.py +275 -0
  308. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/export_ops.py +554 -0
  309. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_confirmation.py +1316 -0
  310. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_io.py +299 -0
  311. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_lifecycle.py +730 -0
  312. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_verification.py +405 -0
  313. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/incidents.py +1005 -0
  314. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/lesson-replay-cases.json +20 -0
  315. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/lesson_ledger.py +241 -0
  316. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/lesson_replay.py +272 -0
  317. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/life_ledger.py +668 -0
  318. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/mistake-book.md +130 -0
  319. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/patterns.py +684 -0
  320. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/receipt_contract.py +269 -0
  321. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/schema.py +1192 -0
  322. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/sync_ops.py +940 -0
  323. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/tool_experience.py +683 -0
  324. bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/verify_life.py +1597 -0
  325. bugx_cli-0.1.1.data/data/share/bugx-agent/core/lesson-ledger.json +275 -0
  326. bugx_cli-0.1.1.data/data/share/bugx-agent/core/locales/README.md +19 -0
  327. bugx_cli-0.1.1.data/data/share/bugx-agent/core/locales/en-US.json +462 -0
  328. bugx_cli-0.1.1.data/data/share/bugx-agent/core/locales/zh-CN.json +462 -0
  329. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/INTERFACE.md +75 -0
  330. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/README.md +62 -0
  331. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/SPEC.md +25 -0
  332. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/__init__.py +128 -0
  333. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/base.py +717 -0
  334. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/channel_lifecycle.py +751 -0
  335. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/graph_handlers.py +222 -0
  336. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/knowledge_handlers.py +536 -0
  337. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/mining_handlers.py +586 -0
  338. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/resource_prompt_table.py +116 -0
  339. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/retrieval_handlers.py +249 -0
  340. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/rpc_server.py +470 -0
  341. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/supervisor_handlers.py +1461 -0
  342. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/telemetry_handlers.py +227 -0
  343. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/tool_table.py +1030 -0
  344. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/README.md +21 -0
  345. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/__init__.py +1 -0
  346. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/common.py +363 -0
  347. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/environment.py +567 -0
  348. bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/verifier.py +758 -0
  349. bugx_cli-0.1.1.data/data/share/bugx-agent/core/metadata.txt +4 -0
  350. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/README.md +157 -0
  351. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/__init__.py +242 -0
  352. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/capability_plan.py +187 -0
  353. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/capability_planner.py +195 -0
  354. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/domain_archetype.py +542 -0
  355. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/domain_router.py +269 -0
  356. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/dynamic_flow_analyzer.py +533 -0
  357. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/impact_pruner.py +435 -0
  358. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/intent_adjudicator.py +175 -0
  359. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/judge_pipeline.py +1246 -0
  360. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/logic_analysis.py +419 -0
  361. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/prompt_harness.py +1704 -0
  362. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/source_inspector.py +267 -0
  363. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/spec_harvester.py +449 -0
  364. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/target_sandbox_manager.py +573 -0
  365. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/test_capability_verifier.py +1364 -0
  366. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/tools-kb.md +38 -0
  367. bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/unit_kind.py +122 -0
  368. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/INTERFACE.md +83 -0
  369. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/README.md +51 -0
  370. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/SPEC.md +36 -0
  371. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/__init__.py +76 -0
  372. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/android_probe.py +552 -0
  373. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/base.py +147 -0
  374. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/codebase_memory_probe.py +647 -0
  375. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/desktop_probe.py +342 -0
  376. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/differential_probe.py +434 -0
  377. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/efficiency_probe.py +232 -0
  378. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ios_binary_probe.py +472 -0
  379. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/memory_probe.py +392 -0
  380. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/miniprogram_probe.py +385 -0
  381. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/mobile_probe.py +466 -0
  382. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/native_probe.py +302 -0
  383. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/openwiki_probe.py +263 -0
  384. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/pattern_probe.py +453 -0
  385. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/platform_probe.py +424 -0
  386. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/probe_registry.py +1770 -0
  387. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sast_fixture_corpus.py +340 -0
  388. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sast_probe.py +1510 -0
  389. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sast_rules.py +1481 -0
  390. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sca_scanner.py +779 -0
  391. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_accessibility.py +149 -0
  392. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_audit.py +513 -0
  393. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_contract.py +273 -0
  394. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_evidence.py +212 -0
  395. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_measurements.py +314 -0
  396. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_repair.py +250 -0
  397. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_review.py +133 -0
  398. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_storybook.py +107 -0
  399. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_tokens.py +185 -0
  400. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_visual_diff.py +131 -0
  401. bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/web_probe.py +714 -0
  402. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/INTERFACE.md +62 -0
  403. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/README.md +53 -0
  404. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/SPEC.md +28 -0
  405. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/__init__.py +201 -0
  406. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/arbitrator.py +316 -0
  407. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/constants.py +247 -0
  408. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/detector.py +399 -0
  409. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/extractors.py +836 -0
  410. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/fingerprint.py +116 -0
  411. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/storage.py +258 -0
  412. bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/strategy.py +301 -0
  413. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/README.md +35 -0
  414. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/codex_dialog_dispatch.md +9 -0
  415. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/command_routing_en.md +42 -0
  416. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/command_routing_zh.md +42 -0
  417. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/l0_router.md +47 -0
  418. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/anti_patterns.md +16 -0
  419. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/concurrency_rules.md +14 -0
  420. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/memory_leak_rules.md +13 -0
  421. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/prompt_injection_defense.md +13 -0
  422. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_explore.md +31 -0
  423. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_gate.md +43 -0
  424. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_mutate.md +42 -0
  425. bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_repair.md +85 -0
  426. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/README.md +74 -0
  427. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/__init__.py +169 -0
  428. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/fix_watchlist.py +391 -0
  429. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/l7_dynamic.py +418 -0
  430. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/l7_repair_loop.py +462 -0
  431. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/l7_selfcheck.py +862 -0
  432. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/minimize_repro.py +466 -0
  433. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/patch_synthesizer.py +617 -0
  434. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/regression_pack.py +379 -0
  435. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_fixer.py +910 -0
  436. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_loop.py +311 -0
  437. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_repair.py +348 -0
  438. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_rounds.py +212 -0
  439. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_scope.py +281 -0
  440. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/self_heal.py +604 -0
  441. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/test_generator.py +1108 -0
  442. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/test_quality_auditor.py +410 -0
  443. bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/test_strategy.py +511 -0
  444. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/INTERFACE.md +59 -0
  445. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/README.md +69 -0
  446. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/SPEC.md +28 -0
  447. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/__init__.py +47 -0
  448. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/attestation.py +228 -0
  449. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/authority.py +255 -0
  450. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/finding_report.py +418 -0
  451. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/formal_report_builder.py +924 -0
  452. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/html_renderers.py +696 -0
  453. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/models.py +759 -0
  454. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/pdf_exporter.py +231 -0
  455. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/projects_assets.py +730 -0
  456. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/report_client.py +743 -0
  457. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/report_data_builder.py +388 -0
  458. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/report_share.py +459 -0
  459. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/sast_bridge.py +116 -0
  460. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/server.py +832 -0
  461. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/visual_report_builder.py +796 -0
  462. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/web-conformance.md +168 -0
  463. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/web_conformance.py +428 -0
  464. bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/workbench_assets.py +484 -0
  465. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/INTERFACE.md +20 -0
  466. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/README.md +161 -0
  467. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/SPEC.md +25 -0
  468. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/__init__.py +3 -0
  469. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/code_analyzer.py +1720 -0
  470. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/codebase_memory_bridge.py +337 -0
  471. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/context_assembler.py +240 -0
  472. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/corpus_fetch.py +369 -0
  473. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/graph_ego.py +597 -0
  474. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/knowledge_auto.py +662 -0
  475. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/knowledge_sources.py +168 -0
  476. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/knowledge_sync.py +1003 -0
  477. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/memory_store.py +480 -0
  478. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/query_planner.py +1020 -0
  479. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/rrf_engine.py +137 -0
  480. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/slice_extractor.py +1209 -0
  481. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/slice_normalizer.py +373 -0
  482. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/slice_spec.py +357 -0
  483. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/symbol_index.py +1151 -0
  484. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/universal_code_matcher.py +622 -0
  485. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/xerj_bridge.py +476 -0
  486. bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/xerj_supervisor.py +362 -0
  487. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/README.md +33 -0
  488. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/PROVENANCE.json +30 -0
  489. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/crypto.yaml +36 -0
  490. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/network.yaml +20 -0
  491. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/resilience.yaml +47 -0
  492. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/storage.yaml +48 -0
  493. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/LICENSE +173 -0
  494. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/PROVENANCE.json +270 -0
  495. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-asymmetric-key-pair-used-for-multiple-purposes.yml +13 -0
  496. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-backup-manifest.yml +24 -0
  497. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-event-bound.yml +49 -0
  498. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-invalidated-enrollment.yml +11 -0
  499. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-no-confirmation-required.yml +10 -0
  500. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-validity-duration.yml +24 -0
  501. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-broken-encryption-algorithms.yaml +9 -0
  502. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-broken-encryption-modes.yaml +13 -0
  503. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-content-provider-exported.yml +35 -0
  504. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-custom-deeplink-scheme.yml +29 -0
  505. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-dangerous-app-permissions.yaml +65 -0
  506. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-data-unencrypted-shared-storage-no-user-interaction-apis.yml +36 -0
  507. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-data-unencrypted-shared-storage-no-user-interaction-manifest.yml +15 -0
  508. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-debuggable-flag.yml +10 -0
  509. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-debugger-checks.yml +12 -0
  510. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-deeplink-autoverify-missing.yml +33 -0
  511. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-deeplink-unvalidated-parameter.yml +11 -0
  512. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-device-passcode-present.yml +17 -0
  513. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-fileprovider-broad-scope.yml +46 -0
  514. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-hardcoded-crypto-keys-usage.yml +14 -0
  515. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-hardcoded-security-provider.yaml +18 -0
  516. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-implicit-intent-internal-communication.yml +30 -0
  517. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-implicit-intent-leaking-extras.yml +29 -0
  518. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-input-field-usage.yml +11 -0
  519. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-key-generation-with-insufficient-key-length.yml +21 -0
  520. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-keyboard-cache-input-types.yml +10 -0
  521. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-local-storage-input-validation.yml +48 -0
  522. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-native-debugger-checks.yml +12 -0
  523. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-checkservertrusted.yml +12 -0
  524. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-hostname-verification.yml +11 -0
  525. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-insecure-trust-anchors.yml +11 -0
  526. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-onreceivedsslerror.yml +12 -0
  527. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-non-random-use.yml +16 -0
  528. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-object-deserialization.yml +14 -0
  529. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-overlay-protection.yml +68 -0
  530. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-pendingintent-mutable.yml +39 -0
  531. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-random-apis-insufficient-entropy.yml +17 -0
  532. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-root-detection.yaml +59 -0
  533. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sdk-version.yml +10 -0
  534. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sensitive-data-in-notifications-manifest.yml +17 -0
  535. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sensitive-data-in-notifications.yml +11 -0
  536. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sensitive-data-in-screenshot.yml +18 -0
  537. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sql-injection-contentprovider.yml +17 -0
  538. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-ssl-socket-hostnameverifier.yml +15 -0
  539. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-strictmode.yml +10 -0
  540. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-system-alert-window.yml +9 -0
  541. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-allow-local-access.yml +15 -0
  542. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-bridges.yml +28 -0
  543. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-safebrowsing.yml +20 -0
  544. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-url-handlers.yml +41 -0
  545. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/PROVENANCE.json +26 -0
  546. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/network.yaml +37 -0
  547. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/platform.yaml +36 -0
  548. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/storage.yaml +48 -0
  549. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/LICENSE +165 -0
  550. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/PROVENANCE.json +58 -0
  551. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/auth.yaml +59 -0
  552. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/crypto.yaml +66 -0
  553. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/jailbreak.yaml +14 -0
  554. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/keyboard.yaml +34 -0
  555. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/logging.yaml +23 -0
  556. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/network.yaml +55 -0
  557. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/resilience.yaml +29 -0
  558. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/secrets.yaml +33 -0
  559. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/storage.yaml +29 -0
  560. bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/webview.yaml +32 -0
  561. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/README.md +198 -0
  562. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/__init__.py +3 -0
  563. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/bugx_logging.py +1464 -0
  564. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/daemon_runner.py +623 -0
  565. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/fixture_solidify.py +444 -0
  566. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/global_telemetry.py +549 -0
  567. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/incident_eval.py +148 -0
  568. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/interaction.py +605 -0
  569. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/interaction_store.py +435 -0
  570. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/interactive_menu.py +95 -0
  571. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/log_analytics.py +922 -0
  572. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/mining_quality_framework.py +1387 -0
  573. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/model_runner.py +732 -0
  574. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/platform_adapter.py +579 -0
  575. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/prep_validate.py +478 -0
  576. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_graph.py +827 -0
  577. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_init.py +481 -0
  578. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_profile.py +224 -0
  579. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_settings.py +964 -0
  580. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/provider_window.py +97 -0
  581. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/resume_ticket.py +115 -0
  582. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/scenario_eval.py +856 -0
  583. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/seed_drill.py +549 -0
  584. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/self_audit.py +550 -0
  585. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/session_profile.py +205 -0
  586. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/setup_ui_env.py +229 -0
  587. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/startup_environment.py +859 -0
  588. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/sync_store.py +1421 -0
  589. bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/tool_install_targets.py +18 -0
  590. bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/README.md +35 -0
  591. bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/agent-graph.schema.json +368 -0
  592. bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/attack-graph.schema.json +88 -0
  593. bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/evidence-bundle.schema.json +33 -0
  594. bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/skill-pack.schema.json +230 -0
  595. bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/worker-checkpoint.schema.json +119 -0
  596. bugx_cli-0.1.1.data/data/share/bugx-agent/core/secure_atomic.py +289 -0
  597. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/README.md +55 -0
  598. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/c.txt +29 -0
  599. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/cpp.txt +32 -0
  600. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/css.txt +70 -0
  601. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/go.txt +46 -0
  602. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/java.txt +30 -0
  603. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/javascript.txt +55 -0
  604. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/kotlin.txt +28 -0
  605. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/python.txt +71 -0
  606. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/rust.txt +53 -0
  607. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/swift.txt +29 -0
  608. bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/typescript.txt +29 -0
  609. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/README.md +53 -0
  610. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/__init__.py +189 -0
  611. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/bugx_docs_mcp_server.py +418 -0
  612. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/bugx_mcp_server.py +1161 -0
  613. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/mcp_runtime.py +968 -0
  614. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/mcp_session_proof.py +605 -0
  615. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/mobile_ui_inspector.py +405 -0
  616. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/skill_pack.py +1214 -0
  617. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/skill_synthesizer.py +1153 -0
  618. bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/tools_kb.py +313 -0
  619. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/INTERFACE.md +121 -0
  620. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/README.md +209 -0
  621. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/SPEC.md +25 -0
  622. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/__init__.py +175 -0
  623. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/audit_supervisor.py +1015 -0
  624. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/budget_governor.py +1254 -0
  625. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/checkpoint_handler.py +368 -0
  626. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/checkpoint_pipeline.py +1564 -0
  627. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/checkpoint_sync.py +653 -0
  628. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/claim_events.py +74 -0
  629. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/claim_sync.py +590 -0
  630. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/cli.py +812 -0
  631. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/context_sync.py +55 -0
  632. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/coverage_sync.py +115 -0
  633. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finding_commit.py +470 -0
  634. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finding_sync.py +688 -0
  635. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finding_workflow.py +676 -0
  636. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finish_policy.py +224 -0
  637. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finish_sync.py +185 -0
  638. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/graph_sync.py +669 -0
  639. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/lease_manager.py +788 -0
  640. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/lifecycle_blocks.py +129 -0
  641. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/next_round_sync.py +126 -0
  642. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/observability.py +140 -0
  643. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/recovery_sync.py +165 -0
  644. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/rejection_remedies.py +355 -0
  645. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/round_governor.py +306 -0
  646. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/serial_authorization.py +544 -0
  647. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/start_sync.py +87 -0
  648. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/state_store.py +249 -0
  649. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/supervisor_host.py +511 -0
  650. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/supervisor_models.py +1143 -0
  651. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/systemic_failure.py +104 -0
  652. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/task_scheduler.py +1640 -0
  653. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_checkpoint.py +230 -0
  654. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_execution.py +265 -0
  655. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_handoff.py +192 -0
  656. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_lifecycle.py +396 -0
  657. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_runtime.py +1005 -0
  658. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_sync.py +89 -0
  659. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/README.md +36 -0
  660. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/__init__.py +0 -0
  661. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/exceptions.py +52 -0
  662. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/graph_models.py +357 -0
  663. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/path_containment.py +151 -0
  664. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/target_fingerprint.py +310 -0
  665. bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/worker_claim.py +411 -0
  666. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/INTERFACE.md +50 -0
  667. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/README.md +57 -0
  668. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/SPEC.md +26 -0
  669. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/__init__.py +11 -0
  670. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/__init__.py +27 -0
  671. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/base.py +87 -0
  672. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/bugx.py +102 -0
  673. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/claude.py +222 -0
  674. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/cline.py +407 -0
  675. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/codex.py +260 -0
  676. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/dsh.py +177 -0
  677. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/opencode.py +218 -0
  678. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/pi.py +272 -0
  679. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/registry.py +100 -0
  680. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/zcode.py +312 -0
  681. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/api_routes_post.py +668 -0
  682. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/dispatcher.py +1376 -0
  683. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/docs_session_service.py +473 -0
  684. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/handler.py +674 -0
  685. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/ide_cloud_service.py +526 -0
  686. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/mcp_inspector.py +1747 -0
  687. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/00-base.css +1060 -0
  688. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/01-monitoring.css +802 -0
  689. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/02-header-actions.css +321 -0
  690. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/03-trigger-popover.css +697 -0
  691. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/04-composer.css +628 -0
  692. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/05-skills-center.css +878 -0
  693. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/06-mcp-center.css +623 -0
  694. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/07-skill-detail.css +265 -0
  695. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/08-files-management.css +167 -0
  696. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/09-files-center.css +386 -0
  697. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/10-icons.css +105 -0
  698. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/11-project-options.css +185 -0
  699. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/12-profile-tab.css +383 -0
  700. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/index-CXAsl8mr.js +333 -0
  701. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/index-DHQUtWtx.css +1 -0
  702. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-400-normal-B8Z6Jvzv.woff +0 -0
  703. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-400-normal-C44pakCn.woff2 +0 -0
  704. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-500-normal-Bb4u56_6.woff +0 -0
  705. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-500-normal-BdVUvljg.woff2 +0 -0
  706. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-400-normal-CWV284fw.woff2 +0 -0
  707. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-400-normal-DLkyKLvH.woff +0 -0
  708. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-500-normal-8-8HP2PF.woff +0 -0
  709. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-500-normal-DaDZE_Na.woff2 +0 -0
  710. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-400-normal-BccYJ-vZ.woff +0 -0
  711. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-400-normal-Cw5-AHNN.woff2 +0 -0
  712. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-500-normal-By8GFJzz.woff2 +0 -0
  713. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-500-normal-z-Q6FFuG.woff +0 -0
  714. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-400-normal-DJ5YJwmz.woff2 +0 -0
  715. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-400-normal-Dn3IlU-Z.woff +0 -0
  716. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-500-normal-CUHe9xxf.woff2 +0 -0
  717. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-500-normal-DVVamBqs.woff +0 -0
  718. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-400-normal-CEpydyUl.woff +0 -0
  719. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-400-normal-Cp7z-ARB.woff2 +0 -0
  720. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-500-normal-BYjRCDVy.woff2 +0 -0
  721. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-500-normal-D-qasQTj.woff +0 -0
  722. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-400-normal-BbG3LG1A.woff2 +0 -0
  723. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-400-normal-DR1UuFon.woff +0 -0
  724. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-500-normal-8N8MYVKB.woff +0 -0
  725. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-500-normal-Bi3OSTTW.woff2 +0 -0
  726. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/design-tokens.css +113 -0
  727. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/favicon.png +0 -0
  728. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/icon-192.png +0 -0
  729. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/index.html +55 -0
  730. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/manifest.webmanifest +19 -0
  731. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/project-settings.js +9602 -0
  732. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/sw.js +8 -0
  733. bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/workspace_service.py +218 -0
  734. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/agents/bugx.md +27 -0
  735. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/dsh-patch.yml +18 -0
  736. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/mcp/cordis.patch.yml +4 -0
  737. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/mcp/index.js +219 -0
  738. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/mcp/package.json +28 -0
  739. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/skills/bugx/SKILL.md +70 -0
  740. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/skills/bugx-dsh/SKILL.md +229 -0
  741. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/client.js +87 -0
  742. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/cordis.patch.yml +4 -0
  743. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/index.js +7 -0
  744. bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/package.json +27 -0
  745. bugx_cli-0.1.1.data/data/share/bugx-agent/mcp-lock.json +3075 -0
  746. bugx_cli-0.1.1.data/data/share/bugx-agent/opencode.json +129 -0
  747. bugx_cli-0.1.1.data/data/share/bugx-agent/pi/extensions/bugx/README.md +12 -0
  748. bugx_cli-0.1.1.data/data/share/bugx-agent/pi/extensions/bugx/index.ts +299 -0
  749. bugx_cli-0.1.1.data/data/share/bugx-agent/pi/extensions/bugx/manifest.json +11 -0
  750. bugx_cli-0.1.1.data/data/share/bugx-agent/pi/skills/bugx/SKILL.md +69 -0
  751. bugx_cli-0.1.1.data/data/share/bugx-agent/plugins/bugx/skills/bugx-claude/SKILL.md +326 -0
  752. bugx_cli-0.1.1.data/data/share/bugx-agent/plugins/bugx/skills/bugx-opencode/SKILL.md +129 -0
  753. bugx_cli-0.1.1.data/data/share/bugx-agent/plugins/bugx/skills/bugx-zcode/SKILL.md +459 -0
  754. bugx_cli-0.1.1.data/data/share/bugx-agent/workbuddy/connector-meta.json +19 -0
  755. bugx_cli-0.1.1.data/data/share/bugx-agent/workbuddy/icon.png +0 -0
  756. bugx_cli-0.1.1.data/data/share/bugx-agent/workbuddy/skills/bugx/SKILL.md +70 -0
  757. bugx_cli-0.1.1.dist-info/METADATA +335 -0
  758. bugx_cli-0.1.1.dist-info/RECORD +762 -0
  759. bugx_cli-0.1.1.dist-info/WHEEL +5 -0
  760. bugx_cli-0.1.1.dist-info/entry_points.txt +2 -0
  761. bugx_cli-0.1.1.dist-info/licenses/LICENSE +55 -0
  762. bugx_cli-0.1.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1151 @@
1
+ #!/usr/bin/env python3
2
+ """为 BugX 建立轻量、零依赖的源码符号索引。
3
+
4
+ Python 使用标准库 AST 精确解析;其他受支持语言使用保守的声明级扫描器。
5
+ 索引既可以供人查看,也可以让 module_coverage 把文件继续拆到函数、类、方法、
6
+ 路由处理器等可独立审计单元。解析失败会显式记录,不会静默把失败当成无符号文件。
7
+ """
8
+ from __future__ import annotations
9
+ # --- 引擎导入根(直接执行脚本时自举 core.* 命名空间)---
10
+ import sys as _sys
11
+ from pathlib import Path as _Path
12
+
13
+ for _p in _Path(__file__).resolve().parents:
14
+ if (_p / "core" / "bugx.md").is_file():
15
+ if str(_p) not in _sys.path:
16
+ _sys.path.insert(0, str(_p))
17
+ break
18
+ del _p
19
+ import sys
20
+ from pathlib import Path
21
+
22
+
23
+ import argparse
24
+ import ast
25
+ import json
26
+ import hashlib
27
+ import os
28
+ import re
29
+ from dataclasses import asdict, dataclass, field, replace
30
+ from fnmatch import fnmatchcase
31
+
32
+ SCHEMA_VERSION = 2
33
+ # These directories belong to the host/agent/runtime rather than the product
34
+ # being audited. They are excluded at every depth: a checked-out worktree
35
+ # under .claude/worktrees is still another branch, not another product module.
36
+ #
37
+ # DOC-239:已迁移宿主(``opencode`` / ``cline`` / ...)的目录只能来自
38
+ # ``core/hosts/<host>.py``(``install.marker`` / ``generated_dirs``),不得在此
39
+ # 重复声明;下面只剩**未迁移宿主**与通用工具目录的待迁移基线。
40
+ _LEGACY_HOST_RUNTIME_DIRS = {
41
+ ".claude", ".pi", ".agents", ".dsh", ".gstack", ".mirasim",
42
+ ".bugx", ".code-review-graph",
43
+ ".workbuddy", ".codebuddy", ".qoder", ".trea", ".trae", ".trae-cn", ".zcode",
44
+ }
45
+
46
+
47
+ def is_engine_namespace_segment(part: str) -> bool:
48
+ """任一目录分量是否属于 BugX 引擎自己的运行态命名空间。
49
+
50
+ ``_LEGACY_HOST_RUNTIME_DIRS`` 只登记了确切的 ``.bugx``,而引擎与宿主 AI
51
+ 会派生**同前缀**的兄弟目录:``.bugx-audit-artifacts``(host 写探针/复现
52
+ 脚本)、``.bugx-patches``(PE 工单补丁包)、``.bugx-cache`` ……。这些全部
53
+ 是审计产物而不是被审产品材料。
54
+
55
+ 实测后果(bugx-audit-dsh 靶场):宿主在项目根写下
56
+ ``.bugx-audit-artifacts/repro.py`` 后,它被当成 3 个新内部单元
57
+ (``probe_sqli.py``、``repro.py::record``、``repro.py::__module__``)并入
58
+ 清单,``post`` 随即报「符号索引不完整」;宿主删掉文件后单元又变
59
+ ``removed``,``workspace`` 指纹反复漂移触发 ``target_rebound``,覆盖状态
60
+ 在 ``covered → stale → pending → removed`` 之间来回翻烧。
61
+
62
+ 前缀匹配而不是枚举名单:新派生的运行态目录不会因为漏登记再次污染覆盖。
63
+ 用户自己的 ``.bugxfoo`` 产品目录同样被排除,但这与 ``.git*`` 的既有约定
64
+ 一致——点前缀命名空间归工具所有。
65
+ """
66
+ return part == ".bugx" or part.startswith(".bugx-") or part.startswith(".bugx_")
67
+
68
+
69
+ def _plugin_host_runtime_dirs() -> set[str]:
70
+ """已迁移插件声明的宿主目录(模块布局残缺时 fail-soft 为空集)。"""
71
+
72
+ try: # 引擎运行时:``core/`` 在 sys.path 上
73
+ from core.host_runtime.host_registry import host_workspace_dirs
74
+ except ImportError: # pragma: no cover - 仅模块被单独拷出时发生
75
+ return set()
76
+ return set(host_workspace_dirs())
77
+
78
+
79
+ #: 引擎自产的运行态目录(**目录名**,按路径分量匹配)。
80
+ #: 自包含引擎副本布局把 Session/Round 账本放在项目根的 ``pollings/`` 下
81
+ #: (见 ``launch_phases.common.pollings_root``),而不是 ``.bugx/`` 内。
82
+ #: 不排除它们会把 ``findings.json`` 当成被审源码资产,要求给出覆盖单元与
83
+ #: 证据(实测 ``post --final`` 报 "#3 findings.json 缺证据")。
84
+ RUNTIME_ARTIFACT_DIRS = {"pollings", "receipts", "artifacts", "backups"}
85
+
86
+ HOST_RUNTIME_DIRS = (
87
+ _LEGACY_HOST_RUNTIME_DIRS | _plugin_host_runtime_dirs() | RUNTIME_ARTIFACT_DIRS
88
+ )
89
+ HOST_ROOT_CONFIG_NAMES = {
90
+ "opencode.json", ".mcp.json",
91
+ }
92
+ DEPENDENCY_OR_GENERATED_DIRS = {
93
+ ".git", "node_modules", "target", "dist", ".venv", "venv", "__pycache__",
94
+ ".gradle", "vendor", "third_party", ".pytest_cache", ".ruff_cache",
95
+ }
96
+ # Keep the old public name for callers that used it, but do not use it as a
97
+ # blunt ``any path segment`` filter: product code may legitimately contain a
98
+ # directory named ``build``.
99
+ EXCLUDED_DIRS = HOST_RUNTIME_DIRS | DEPENDENCY_OR_GENERATED_DIRS | {
100
+ "build", "tests", "test", "__tests__", "docs", "examples", "evals",
101
+ }
102
+ TOP_LEVEL_SOURCE_EXCLUDED_DIRS = {
103
+ "build", "tests", "test", "__tests__", "docs", "examples", "evals",
104
+ # BugX 自身产物约定:patch-forge 的 PE 工单补丁包(repro/tests 记录),
105
+ # 与 plugins/bugx 同类——是引擎历史工件而非被测产品代码。
106
+ ".bugx-patches",
107
+ }
108
+ # 资产发现(include_test_assets=True)额外排除的顶层目录:BugX 双轨报告/
109
+ # 收据默认输出到 ``verification/evals/oss``(HTML/JSON 均在资产扩展名清单内)——审计
110
+ # 产物喂回覆盖清单是自增强污染(实测 evals 报告被列为审计单元)。
111
+ TOP_LEVEL_ASSET_EXCLUDED_DIRS = {
112
+ "verification",
113
+ ".bugx-patches",
114
+ }
115
+ SOURCE_EXTS = {
116
+ ".py", ".js", ".mjs", ".cjs", ".jsx", ".ts", ".tsx", ".java", ".kt", ".kts", ".go",
117
+ ".rs", ".swift", ".c", ".h", ".cc", ".cpp", ".cxx", ".cs", ".rb",
118
+ ".php", ".vue", ".svelte",
119
+ }
120
+ AUDIT_ASSET_EXTS = {
121
+ ".sh", ".bash", ".zsh", ".fish", ".sql", ".yaml", ".yml", ".toml",
122
+ ".json", ".jsonc", ".xml", ".ini", ".cfg", ".conf", ".properties",
123
+ ".proto", ".graphql", ".gql", ".tf", ".tfvars", ".html", ".css",
124
+ ".scss", ".sass", ".less", ".lock",
125
+ }
126
+ AUDIT_ASSET_NAMES = {
127
+ "Dockerfile", "Makefile", "GNUmakefile", "CMakeLists.txt", "Procfile",
128
+ "Justfile", "go.mod", "go.sum", "Cargo.toml", "Cargo.lock", "pom.xml",
129
+ "build.gradle", "settings.gradle", "Gemfile", "Gemfile.lock",
130
+ "composer.json", "requirements.txt", "requirements-dev.txt", "Pipfile",
131
+ "Pipfile.lock", "package-lock.json", "pnpm-lock.yaml", "yarn.lock",
132
+ "poetry.lock", "uv.lock", "setup.cfg", "tox.ini",
133
+ ".pre-commit-config.yaml", ".env.example",
134
+ }
135
+ RUNTIME_ARTIFACT_NAMES = {
136
+ "bugx-life.json", "bugx-life.json.lock", "bugx-runtime.json",
137
+ "bugx-runtime.json.lock", "bugx-runtime.lock", "audit-supervisor.json",
138
+ "audit-supervisor.json.lock",
139
+ "coverage-evidence.json", "coverage-evidence.json.lock", "lesson-review.json",
140
+ "lesson-review.json.lock", "module-coverage.md", "prep-record.md",
141
+ # Flat/legacy launch mode writes the formal lifecycle artifacts at the
142
+ # project root. Formal projects are already protected by the .bugx
143
+ # directory exclusion; keeping the names here protects the legacy mode
144
+ # without excluding a same-named product file in a subdirectory.
145
+ "life.json", "runtime.json", "runtime.json.lock", "supervisor.json",
146
+ "supervisor.json.lock", "state.json", "current.json", "events.jsonl",
147
+ "report.md", "conclusion.json", "integrity.json", "inventory-diff.json",
148
+ "finding-ledger.json", "finding-ledger.json.lock", ".finding-ledger.json.lock",
149
+ "findings.json", "findings.json.lock", ".findings.json.lock",
150
+ "audit-campaign.json", "finding-lifecycle.json", "bugx-life.json.snapshot",
151
+ "lesson-ledger.sqlite3.journal-mode.lock",
152
+ # 项目错题集是引擎运行态(``common.LESSON_LEDGER_FILE``:项目根的
153
+ # lesson-ledger.json,由 lesson_ledger.py 写入),旧清单漏登记它,
154
+ # 结果它被当成**被审产品资产**参与覆盖门禁:新工程刚初始化就必然
155
+ # 报「最小单元清单漏列源码或行为资产: lesson-ledger.json」,
156
+ # 而它根本不该有覆盖单元。同类运行态(finding-ledger.json 等)已在册。
157
+ "lesson-ledger.json", "lesson-ledger.json.lock",
158
+ # 云端 onboarding 写入项目根的云端身份标记(cloud_onboard.py),
159
+ # 属引擎运行态而非产品材料——与 .bugx 目录同类。
160
+ ".bugx-project.json",
161
+ }
162
+
163
+
164
+ class SourceDiscoveryError(ValueError):
165
+ """源码枚举不完整,调用方不得继续声称全覆盖。"""
166
+
167
+
168
+ @dataclass(frozen=True)
169
+ class Symbol:
170
+ name: str
171
+ qualified_name: str
172
+ kind: str
173
+ start_line: int
174
+ end_line: int
175
+ parent: str | None
176
+ parser: str
177
+ start_byte: int | None = field(default=None, compare=False, repr=False)
178
+
179
+ @property
180
+ def scope_name(self) -> str:
181
+ return self.qualified_name
182
+
183
+
184
+ def _gitignore_rules(root: Path) -> list[str]:
185
+ """Read the root ignore file once for both source and asset discovery."""
186
+ try:
187
+ lines = (root / ".gitignore").read_text(encoding="utf-8").splitlines()
188
+ except (OSError, UnicodeError):
189
+ return []
190
+ return [
191
+ line.strip() for line in lines
192
+ if line.strip() and not line.lstrip().startswith("#")
193
+ ]
194
+
195
+
196
+ def _gitignore_matches(relative: Path, *, is_dir: bool, rules: list[str]) -> bool:
197
+ """Apply the root .gitignore's last matching rule to a relative path."""
198
+ # 只剥掉调用方可能带来的 "./" 前缀;str.lstrip("./") 是字符集剥离,
199
+ # 会把点前缀文件名(.bugx-project.json、.env、.github…)的开头点吃掉,
200
+ # 导致 gitignore 名单对全部隐藏文件静默失效——而引擎自产工件恰恰
201
+ # 集中在点前缀命名空间(实测 .myapp-state.json 已入 .gitignore 仍被
202
+ # 发现)。
203
+ raw_path = relative.as_posix()
204
+ path = raw_path[2:] if raw_path.startswith("./") else raw_path
205
+ ignored = False
206
+ for raw in rules:
207
+ negated = raw.startswith("!")
208
+ pattern = raw[1:] if negated else raw
209
+ directory_only = pattern.endswith("/")
210
+ pattern = pattern.rstrip("/").lstrip("/")
211
+ if not pattern or (directory_only and not is_dir):
212
+ continue
213
+ if "/" not in pattern:
214
+ matched = any(fnmatchcase(part, pattern) for part in Path(path).parts)
215
+ else:
216
+ matched = fnmatchcase(path, pattern) or fnmatchcase(path, f"*/{pattern}")
217
+ if matched:
218
+ ignored = not negated
219
+ return ignored
220
+
221
+
222
+ def _generated_directory(relative: Path) -> bool:
223
+ """Filter generated variants without hiding product code in src/build."""
224
+ parts = relative.parts
225
+ for index, part in enumerate(parts):
226
+ lowered = part.casefold()
227
+ if lowered == "dist" or lowered.startswith("dist-") \
228
+ or lowered.startswith(".tmp-"):
229
+ return True
230
+ if lowered == "build" and index + 1 < len(parts) \
231
+ and parts[index + 1].casefold() == "generated":
232
+ return True
233
+ return False
234
+
235
+
236
+ _PROJECT_EXCLUDE_TOP_DIRS_CACHE: dict[Path, frozenset[str]] = {}
237
+
238
+
239
+ def _project_exclude_top_dirs(root: Path) -> frozenset[str]:
240
+ """项目级覆盖排除,两路来源取并集(AI 复核为主,手工配置为辅):
241
+
242
+ 1. **AI 复核定案**(主通道):``.bugx/knowledge/coverage-review.json``
243
+ 里宿主 AI 逐目录排查后的 ``exclude`` 裁决——裁决带理由/时间/裁决者,
244
+ 换项目时由该机制重新排查,不携带任何项目名清单(DOC-AIREV)。
245
+ 2. **手工覆盖**(辅助):``.bugx/config.json`` 的
246
+ ``coverage.exclude_top_dirs`` 顶层目录名列表,供人工紧急纠偏。
247
+
248
+ 读取失败一律返回空集(fail-open:宁可多扫,不因配置错误吞掉产品代码)。
249
+ """
250
+ cached = _PROJECT_EXCLUDE_TOP_DIRS_CACHE.get(root)
251
+ if cached is not None:
252
+ return cached
253
+ names: set[str] = set()
254
+ try:
255
+ from core.coverage import coverage_ai_review
256
+
257
+ names |= set(coverage_ai_review.excluded_top_dirs(root))
258
+ except Exception: # pragma: no cover - 复核模块缺失/损坏时退回配置通道
259
+ pass
260
+ try:
261
+ cfg = root / ".bugx" / "config.json"
262
+ if cfg.is_file():
263
+ data = json.loads(cfg.read_text(encoding="utf-8"))
264
+ raw = (data.get("coverage") or {}).get("exclude_top_dirs")
265
+ if isinstance(raw, list):
266
+ names |= {
267
+ str(item).strip().strip("/")
268
+ for item in raw
269
+ if isinstance(item, str) and item.strip().strip("/")
270
+ }
271
+ except (OSError, ValueError, AttributeError):
272
+ pass
273
+ frozen = frozenset(names)
274
+ _PROJECT_EXCLUDE_TOP_DIRS_CACHE[root] = frozen
275
+ return frozen
276
+
277
+
278
+ def _directory_is_excluded(
279
+ relative: Path, *, include_test_assets: bool,
280
+ gitignore_rules: list[str] | None = None, is_dir: bool = True,
281
+ project_root: Path | None = None,
282
+ ) -> bool:
283
+ parts = set(relative.parts)
284
+ if parts & (HOST_RUNTIME_DIRS | DEPENDENCY_OR_GENERATED_DIRS) \
285
+ or any(is_engine_namespace_segment(part) for part in parts) \
286
+ or _generated_directory(relative):
287
+ return True
288
+ if include_test_assets and relative.parts and relative.parts[0] in TOP_LEVEL_ASSET_EXCLUDED_DIRS:
289
+ return True
290
+ if not include_test_assets and relative.parts and relative.parts[0] in TOP_LEVEL_SOURCE_EXCLUDED_DIRS:
291
+ return True
292
+ if project_root is not None and relative.parts and relative.parts[0] in _project_exclude_top_dirs(project_root):
293
+ return True
294
+ return _gitignore_matches(relative, is_dir=is_dir, rules=gitignore_rules or [])
295
+
296
+
297
+ _ENGINE_PLUGIN_PACKAGE_PREFIX = ("plugins", "bugx")
298
+ _ENGINE_PLUGIN_PACKAGE_CACHE: dict[Path, bool] = {}
299
+
300
+
301
+ def _is_engine_plugin_package(relative: Path, root: Path) -> bool:
302
+ """安装器写入项目的 BugX 自产插件包不是被审计产品材料。
303
+
304
+ ``bugx install`` 会在项目根写入可分发的 ``plugins/bugx/.zcode-plugin``
305
+ 插件包(清单 + agents);它属于宿主集成产物而非用户源码,与
306
+ ``.bugx/`` 同类。判定用指纹而非目录名:相对路径必须以
307
+ ``plugins/bugx/`` 开头,且该目录下的清单声明 ``name == "bugx"``。
308
+ 用户自己的 ``plugins/bugx`` 产品代码(无该清单或声明其他 name)
309
+ 不受影响。结果按 root 缓存,walk 期间零额外 IO。
310
+ """
311
+ parts = relative.parts
312
+ if len(parts) < 2 or parts[:2] != _ENGINE_PLUGIN_PACKAGE_PREFIX:
313
+ return False
314
+ root = root.resolve()
315
+ cached = _ENGINE_PLUGIN_PACKAGE_CACHE.get(root)
316
+ if cached is None:
317
+ cached = False
318
+ manifest = root.joinpath(*_ENGINE_PLUGIN_PACKAGE_PREFIX, ".zcode-plugin", "plugin.json")
319
+ try:
320
+ if manifest.is_file():
321
+ payload = json.loads(manifest.read_text(encoding="utf-8"))
322
+ cached = isinstance(payload, dict) and payload.get("name") == "bugx"
323
+ except (OSError, ValueError):
324
+ cached = False
325
+ _ENGINE_PLUGIN_PACKAGE_CACHE[root] = cached
326
+ return cached
327
+
328
+
329
+ def _is_runtime_artifact(path: Path, root: Path) -> bool:
330
+ """Exclude root-level legacy runtime output and host root configs, not product assets.
331
+
332
+ A project may legitimately contain ``config/runtime.json`` or
333
+ ``docs/report.md``. Runtime names and host configs therefore are not a global
334
+ blacklist; only flat launcher output and root host configs (e.g. opencode.json,
335
+ .mcp.json) directly below the audited root are ignored.
336
+ In the formal layout all runtime files live below ``.bugx`` and are
337
+ excluded by the directory policy before this check matters.
338
+ """
339
+ try:
340
+ relative = path.relative_to(root)
341
+ except ValueError:
342
+ return False
343
+ return relative.parent == Path(".") and (
344
+ path.name in RUNTIME_ARTIFACT_NAMES
345
+ or path.name in HOST_ROOT_CONFIG_NAMES
346
+ )
347
+
348
+
349
+ def _discover_paths(
350
+ root: Path, *, extensions: set[str], names: set[str] | None = None,
351
+ strict: bool = False, include_test_assets: bool = False,
352
+ ) -> list[Path]:
353
+ """Walk the authorized root without following directory symlinks.
354
+
355
+ ``Path.rglob`` silently skips inaccessible subdirectories on some Python
356
+ versions. The audit gate must be able to distinguish an empty directory
357
+ from an incomplete enumeration, so ``os.walk(onerror=...)`` is used here.
358
+ """
359
+ root = root.resolve()
360
+ if not root.is_dir():
361
+ if strict:
362
+ raise SourceDiscoveryError(f"项目根目录不存在或不可访问: {root}")
363
+ return []
364
+ paths: list[Path] = []
365
+ seen_targets: set[Path] = set()
366
+ gitignore_rules = _gitignore_rules(root)
367
+
368
+ def onerror(exc: OSError) -> None:
369
+ if strict:
370
+ raise SourceDiscoveryError(f"项目文件枚举失败: {exc}") from exc
371
+
372
+ try:
373
+ for directory, dirnames, filenames in os.walk(
374
+ root, topdown=True, followlinks=False, onerror=onerror,
375
+ ):
376
+ directory_path = Path(directory)
377
+ relative_dir = directory_path.relative_to(root)
378
+ dirnames[:] = [
379
+ name for name in dirnames
380
+ if not _directory_is_excluded(
381
+ relative_dir / name, include_test_assets=include_test_assets,
382
+ gitignore_rules=gitignore_rules, project_root=root,
383
+ )
384
+ and not _is_engine_plugin_package(relative_dir / name, root)
385
+ ]
386
+ for name in filenames:
387
+ path = directory_path / name
388
+ relative = path.relative_to(root)
389
+ if _is_runtime_artifact(path, root):
390
+ continue
391
+ if _is_engine_plugin_package(relative, root):
392
+ continue
393
+ if _directory_is_excluded(
394
+ relative, include_test_assets=include_test_assets,
395
+ gitignore_rules=gitignore_rules, is_dir=False,
396
+ project_root=root,
397
+ ):
398
+ continue
399
+ if path.suffix.lower() not in extensions and name not in (names or set()):
400
+ continue
401
+ try:
402
+ resolved = path.resolve(strict=True)
403
+ resolved.relative_to(root)
404
+ if not path.is_file() or resolved in seen_targets:
405
+ continue
406
+ seen_targets.add(resolved)
407
+ paths.append(path)
408
+ except ValueError:
409
+ # 指向授权根目录之外的符号链接不属于审计范围。
410
+ continue
411
+ except OSError as exc:
412
+ if strict:
413
+ raise SourceDiscoveryError(f"项目文件枚举失败 {path}: {exc}") from exc
414
+ except OSError as exc:
415
+ if strict:
416
+ raise SourceDiscoveryError(f"项目目录遍历失败 {root}: {exc}") from exc
417
+ return sorted(paths, key=lambda item: str(item.relative_to(root)))
418
+
419
+
420
+ def discover_source_paths(root: Path, strict: bool = False) -> list[Path]:
421
+ """递归返回产品源码,排除依赖、构建产物、测试和 Agent 自身。"""
422
+ return _discover_paths(
423
+ root, extensions=SOURCE_EXTS, strict=strict, include_test_assets=False,
424
+ )
425
+
426
+
427
+ def discover_asset_paths(root: Path, strict: bool = False) -> list[Path]:
428
+ """发现会改变运行行为的配置、依赖、构建、CI 与部署资产。
429
+
430
+ 测试/文档目录不作为源码模块,但其中的脚本和配置仍可能是验收证据,
431
+ 因此资产发现保留这些目录;宿主运行目录和生成/第三方目录仍始终排除。
432
+ """
433
+ return _discover_paths(
434
+ root, extensions=AUDIT_ASSET_EXTS, names=AUDIT_ASSET_NAMES,
435
+ strict=strict, include_test_assets=True,
436
+ )
437
+
438
+
439
+ def _decode_source(raw: bytes) -> str:
440
+ """Decode bytes exactly like ``Path.read_text(encoding="utf-8", errors="replace")``.
441
+
442
+ ``Path.read_text`` opens in universal-newline mode, which rewrites CRLF and
443
+ lone CR to LF. Decoding the cached bytes must do the same, otherwise symbol
444
+ line ranges and ``ast.get_source_segment`` evidence would change on CRLF
445
+ checkouts. The replacement order matters: ``\\r\\n`` first, then ``\\r``.
446
+ """
447
+ return raw.decode("utf-8", errors="replace").replace("\r\n", "\n").replace("\r", "\n")
448
+
449
+
450
+ class SourceContentCache:
451
+ """Per-pass cache of raw source bytes so a pass reads each file once.
452
+
453
+ BugX re-reads every source file two to three times per pass: ``parse_file``
454
+ for symbols, ``file_sha256`` for the content hash, and again when the
455
+ project graph re-parses Python sources. Threading one cache through a pass
456
+ collapses those into a single read per file.
457
+
458
+ Lifetime is deliberately a *single pass* (one ``index_repository`` /
459
+ ``audit_units`` / ``inventory_snapshot`` / ``build_graph`` call), never a
460
+ process-global memo. The audit engine re-runs against a workspace that can
461
+ change between passes (edits, ``git checkout``, generated files), so a
462
+ process-wide cache would silently serve stale content. Read failures are
463
+ not cached, so an unreadable file still raises the same ``OSError`` on every
464
+ attempt and a mid-pass change is never masked by a cached failure.
465
+ """
466
+
467
+ __slots__ = ("_bytes",)
468
+
469
+ def __init__(self) -> None:
470
+ self._bytes: dict[Path, bytes] = {}
471
+
472
+ def read_bytes(self, path: Path) -> bytes:
473
+ """Return the file's bytes, hitting the disk at most once per pass."""
474
+ try:
475
+ return self._bytes[path]
476
+ except KeyError:
477
+ data = path.read_bytes()
478
+ self._bytes[path] = data
479
+ return data
480
+
481
+ def read_text(self, path: Path) -> str:
482
+ """Return the file as text with ``Path.read_text`` newline semantics."""
483
+ return _decode_source(self.read_bytes(path))
484
+
485
+
486
+ def file_sha256(path: Path, cache: SourceContentCache | None = None) -> str:
487
+ """计算文件内容的 SHA-256(1 MiB 分块,避免整文件驻留内存)。
488
+
489
+ 这是全仓文件哈希的唯一实现(QUA-03):``coverage_evidence.sha256_file`` 与
490
+ ``mcp_runtime.sha256_file`` 都复用本函数。本模块保持零本地依赖——它会被
491
+ 复制进隔离的 launch 目录单独运行,不能引入 core 内其它模块。
492
+ """
493
+ if cache is not None:
494
+ return hashlib.sha256(cache.read_bytes(path)).hexdigest()
495
+ digest = hashlib.sha256()
496
+ with path.open("rb") as handle:
497
+ for chunk in iter(lambda: handle.read(1024 * 1024), b""):
498
+ digest.update(chunk)
499
+ return digest.hexdigest()
500
+
501
+
502
+ class _PythonVisitor(ast.NodeVisitor):
503
+ def __init__(self) -> None:
504
+ self.symbols: list[Symbol] = []
505
+ self.parents: list[str] = []
506
+
507
+ def _record(self, node: ast.AST, name: str, kind: str) -> None:
508
+ qualified = ".".join([*self.parents, name])
509
+ self.symbols.append(Symbol(
510
+ name=name,
511
+ qualified_name=qualified,
512
+ kind=kind,
513
+ start_line=int(getattr(node, "lineno", 1)),
514
+ end_line=int(getattr(node, "end_lineno", getattr(node, "lineno", 1))),
515
+ parent=".".join(self.parents) or None,
516
+ parser="python-ast",
517
+ ))
518
+
519
+ def visit_ClassDef(self, node: ast.ClassDef) -> None:
520
+ self._record(node, node.name, "class")
521
+ self.parents.append(node.name)
522
+ self.generic_visit(node)
523
+ self.parents.pop()
524
+
525
+ def visit_FunctionDef(self, node: ast.FunctionDef) -> None:
526
+ kind = "method" if self.parents else "function"
527
+ self._record(node, node.name, kind)
528
+ self.parents.append(node.name)
529
+ self.generic_visit(node)
530
+ self.parents.pop()
531
+
532
+ def visit_AsyncFunctionDef(self, node: ast.AsyncFunctionDef) -> None:
533
+ kind = "async-method" if self.parents else "async-function"
534
+ self._record(node, node.name, kind)
535
+ self.parents.append(node.name)
536
+ self.generic_visit(node)
537
+ self.parents.pop()
538
+
539
+
540
+ def _python_symbols(source: str) -> tuple[list[Symbol], str | None]:
541
+ try:
542
+ tree = ast.parse(source)
543
+ except SyntaxError as exc:
544
+ return [], f"Python 语法错误: line {exc.lineno}: {exc.msg}"
545
+ visitor = _PythonVisitor()
546
+ visitor.visit(tree)
547
+ module_nodes = [
548
+ node for node in tree.body
549
+ if not isinstance(node, (ast.Import, ast.ImportFrom, ast.ClassDef,
550
+ ast.FunctionDef, ast.AsyncFunctionDef))
551
+ and not (
552
+ isinstance(node, ast.Expr)
553
+ and isinstance(getattr(node, "value", None), ast.Constant)
554
+ and isinstance(node.value.value, str)
555
+ )
556
+ ]
557
+ if module_nodes:
558
+ visitor.symbols.append(Symbol(
559
+ name="__module__",
560
+ qualified_name="__module__",
561
+ kind="module",
562
+ start_line=min(int(getattr(node, "lineno", 1)) for node in module_nodes),
563
+ end_line=max(int(getattr(node, "end_lineno", getattr(node, "lineno", 1)))
564
+ for node in module_nodes),
565
+ parent=None,
566
+ parser="python-ast",
567
+ ))
568
+ return visitor.symbols, None
569
+
570
+
571
+ DECLARATION_PATTERNS: dict[str, tuple[tuple[str, str], ...]] = {
572
+ "javascript": (
573
+ ("class", r"^\s*(?:export\s+(?:default\s+)?)?class\s+([A-Za-z_$][\w$]*)"),
574
+ ("function", r"^\s*(?:export\s+)?(?:async\s+)?function\s+"
575
+ r"([A-Za-z_$][\w$]*)\s*\("),
576
+ ("function", r"^\s*(?:export\s+)?(?:const|let|var)\s+"
577
+ r"([A-Za-z_$][\w$]*)\s*=\s*(?:async\s*)?"
578
+ r"(?:\([^)]*\)|[A-Za-z_$][\w$]*)\s*=>"),
579
+ ),
580
+ "jvm": (
581
+ ("class", r"^\s*(?:(?:public|private|protected|internal|abstract|final|open|"
582
+ r"data|sealed)\s+)*(?:class|interface|object|enum\s+class)\s+"
583
+ r"([A-Za-z_$][\w$]*)"),
584
+ ("function", r"^\s*(?:(?:public|private|protected|internal|static|final|open|"
585
+ r"suspend|override|abstract)\s+)*(?:fun\s+|[\w<>\[\],.?]+\s+)"
586
+ r"([A-Za-z_$][\w$]*)\s*\([^;]*\)\s*(?:\{|=|throws\b)"),
587
+ ),
588
+ "go": (
589
+ ("type", r"^\s*type\s+([A-Za-z_]\w*)\s+(?:struct|interface)\b"),
590
+ ("function", r"^\s*func\s+(?:\([^)]*\)\s*)?([A-Za-z_]\w*)\s*\("),
591
+ ),
592
+ "rust": (
593
+ ("type", r"^\s*(?:pub(?:\([^)]*\))?\s+)?(?:struct|enum|trait)\s+([A-Za-z_]\w*)"),
594
+ ("function", r"^\s*(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?(?:unsafe\s+)?"
595
+ r"fn\s+([A-Za-z_]\w*)\s*(?:<[^>]+>)?\s*\("),
596
+ ),
597
+ "swift": (
598
+ ("type", r"^\s*(?:(?:public|private|internal|open|final)\s+)*"
599
+ r"(?:class|struct|enum|protocol|actor)\s+([A-Za-z_]\w*)"),
600
+ ("function", r"^\s*(?:(?:public|private|internal|open|static|class|override|"
601
+ r"mutating)\s+)*func\s+([A-Za-z_]\w*)\s*\("),
602
+ ),
603
+ "c-family": (
604
+ ("type", r"^\s*(?:(?:public|private|protected|internal|static|abstract|sealed|"
605
+ r"partial)\s+)*(?:class|struct|interface|enum)\s+([A-Za-z_]\w*)"),
606
+ ("function", r"^\s*(?:(?:public|private|protected|internal|static|virtual|"
607
+ r"override|inline|constexpr|extern)\s+)*"
608
+ r"[A-Za-z_][\w:<>,*&\[\]\s]*\s+([A-Za-z_]\w*)\s*"
609
+ r"\([^;]*\)\s*(?:\{|=>)"),
610
+ ),
611
+ "ruby": (
612
+ ("type", r"^\s*(?:class|module)\s+([A-Za-z_]\w*(?:::[A-Za-z_]\w*)*)"),
613
+ ("function", r"^\s*def\s+(?:self\.)?([A-Za-z_]\w*[!?=]?)"),
614
+ ),
615
+ "php": (
616
+ ("class", r"^\s*(?:(?:abstract|final)\s+)?(?:class|interface|trait|enum)\s+([A-Za-z_]\w*)"),
617
+ ("function", r"^\s*(?:(?:public|private|protected|static|final|abstract)\s+)*"
618
+ r"function\s+&?([A-Za-z_]\w*)\s*\("),
619
+ ),
620
+ }
621
+ JAVASCRIPT_METHOD_RE = re.compile(
622
+ r"^\s*(?:(?:public|private|protected|static|async|get|set)\s+)*"
623
+ r"([A-Za-z_$][\w$]*)\s*\([^)]*\)\s*\{"
624
+ )
625
+ JAVASCRIPT_CONTROL_WORDS = {"if", "for", "while", "switch", "catch", "with"}
626
+
627
+
628
+ def _language_for(path: Path) -> str:
629
+ suffix = path.suffix.lower()
630
+ if suffix == ".py":
631
+ return "python"
632
+ if suffix in {".js", ".mjs", ".cjs", ".jsx", ".ts", ".tsx", ".vue", ".svelte"}:
633
+ return "javascript"
634
+ if suffix in {".java", ".kt", ".kts"}:
635
+ return "jvm"
636
+ if suffix == ".go":
637
+ return "go"
638
+ if suffix == ".rs":
639
+ return "rust"
640
+ if suffix == ".swift":
641
+ return "swift"
642
+ if suffix in {".c", ".h", ".cc", ".cpp", ".cxx", ".cs"}:
643
+ return "c-family"
644
+ if suffix == ".rb":
645
+ return "ruby"
646
+ return "php"
647
+
648
+
649
+ TREE_SITTER_LANGUAGES = {
650
+ ".js": "javascript", ".mjs": "javascript", ".cjs": "javascript",
651
+ ".jsx": "javascript", ".ts": "typescript", ".tsx": "tsx",
652
+ ".java": "java", ".kt": "kotlin", ".kts": "kotlin", ".go": "go",
653
+ ".rs": "rust", ".swift": "swift", ".c": "c", ".h": "c",
654
+ ".cc": "cpp", ".cpp": "cpp", ".cxx": "cpp", ".cs": "c_sharp",
655
+ ".rb": "ruby", ".php": "php", ".vue": "vue", ".svelte": "svelte",
656
+ }
657
+ TREE_SITTER_NODE_KINDS = {
658
+ "class_declaration": "class", "class_definition": "class",
659
+ "interface_declaration": "type", "object_declaration": "type",
660
+ "struct_item": "type", "struct_specifier": "type", "enum_item": "type",
661
+ "enum_declaration": "type", "trait_item": "type", "protocol_declaration": "type",
662
+ "function_declaration": "function", "function_definition": "function",
663
+ "function_item": "function", "method_definition": "method",
664
+ "method_declaration": "method", "function_method_declaration": "method",
665
+ }
666
+ TREE_SITTER_NAME_TYPES = {
667
+ "identifier", "type_identifier", "property_identifier", "field_identifier",
668
+ "constant", "operator_name", "name",
669
+ }
670
+
671
+
672
+ def _tree_sitter_name(node: object) -> str | None:
673
+ direct = node.child_by_field_name("name")
674
+ if direct is not None:
675
+ return direct.text.decode("utf-8", errors="replace")
676
+ declarator = node.child_by_field_name("declarator")
677
+ queue = [declarator] if declarator is not None else list(node.named_children[:4])
678
+ while queue:
679
+ current = queue.pop(0)
680
+ if current.type in TREE_SITTER_NAME_TYPES:
681
+ return current.text.decode("utf-8", errors="replace")
682
+ queue[0:0] = list(current.named_children[:4])
683
+ return None
684
+
685
+
686
+ def _tree_sitter_symbols(source: str, language: str) -> tuple[list[Symbol], str | None]:
687
+ try:
688
+ from tree_sitter_language_pack import get_parser
689
+ except ImportError:
690
+ return [], "Tree-sitter 后端未安装;安装 bugx-cli[graph]"
691
+ try:
692
+ tree = get_parser(language).parse(source.encode("utf-8"))
693
+ except Exception as exc: # language-pack 对不支持语法抛出多种运行时异常
694
+ return [], f"Tree-sitter 无法加载 {language}: {exc}"
695
+ symbols: list[Symbol] = []
696
+
697
+ def walk(node: object, parents: list[str]) -> None:
698
+ kind = TREE_SITTER_NODE_KINDS.get(node.type)
699
+ name = _tree_sitter_name(node) if kind else None
700
+ child_parents = parents
701
+ if kind and name:
702
+ qualified = ".".join([*parents, name])
703
+ actual_kind = "method" if kind == "function" and parents else kind
704
+ symbols.append(Symbol(
705
+ name=name,
706
+ qualified_name=qualified,
707
+ kind=actual_kind,
708
+ start_line=node.start_point[0] + 1,
709
+ end_line=node.end_point[0] + 1,
710
+ parent=".".join(parents) or None,
711
+ parser=f"tree-sitter-{language}",
712
+ start_byte=node.start_byte,
713
+ ))
714
+ child_parents = [*parents, name]
715
+ for child in node.named_children:
716
+ walk(child, child_parents)
717
+
718
+ walk(tree.root_node, [])
719
+ error = f"Tree-sitter {language} 语法树包含 ERROR 节点" if tree.root_node.has_error else None
720
+ return symbols, error
721
+
722
+
723
+ def _declaration_symbols(source: str, language: str) -> tuple[list[Symbol], None]:
724
+ symbols: list[Symbol] = []
725
+ seen: set[tuple[str, int]] = set()
726
+ lines = source.splitlines()
727
+ for line_number, line in enumerate(lines, 1):
728
+ for kind, pattern in DECLARATION_PATTERNS[language]:
729
+ match = re.search(pattern, line)
730
+ if not match:
731
+ continue
732
+ name = match.group(1)
733
+ key = (name, line_number)
734
+ if key not in seen:
735
+ symbols.append(Symbol(
736
+ name=name,
737
+ qualified_name=name,
738
+ kind=kind,
739
+ start_line=line_number,
740
+ end_line=_declaration_end_line(lines, line_number),
741
+ parent=None,
742
+ parser=f"{language}-declaration",
743
+ ))
744
+ seen.add(key)
745
+ break
746
+ return symbols, None
747
+
748
+
749
+ def _declaration_end_line(lines: list[str], start_line: int) -> int:
750
+ """Estimate a declaration body range for the dependency-free scanner."""
751
+ depth = 0
752
+ saw_brace = False
753
+ for index in range(start_line - 1, len(lines)):
754
+ line = lines[index]
755
+ opening = line.count("{")
756
+ closing = line.count("}")
757
+ if opening:
758
+ saw_brace = True
759
+ depth += opening - closing
760
+ if saw_brace and depth <= 0:
761
+ return index + 1
762
+ return start_line
763
+
764
+
765
+ def _javascript_symbols(source: str) -> tuple[list[Symbol], None]:
766
+ symbols: list[Symbol] = []
767
+ brace_depth = 0
768
+ class_stack: list[tuple[str, int]] = []
769
+ for line_number, line in enumerate(source.splitlines(), 1):
770
+ while class_stack and brace_depth < class_stack[-1][1]:
771
+ class_stack.pop()
772
+ class_match = re.search(DECLARATION_PATTERNS["javascript"][0][1], line)
773
+ pending_class = class_match.group(1) if class_match else None
774
+ if pending_class:
775
+ symbols.append(Symbol(
776
+ name=pending_class,
777
+ qualified_name=pending_class,
778
+ kind="class",
779
+ start_line=line_number,
780
+ end_line=line_number,
781
+ parent=None,
782
+ parser="javascript-declaration",
783
+ ))
784
+ elif class_stack:
785
+ method_match = JAVASCRIPT_METHOD_RE.search(line)
786
+ if method_match and method_match.group(1) not in JAVASCRIPT_CONTROL_WORDS:
787
+ name = method_match.group(1)
788
+ parent = class_stack[-1][0]
789
+ symbols.append(Symbol(
790
+ name=name,
791
+ qualified_name=f"{parent}.{name}",
792
+ kind="method",
793
+ start_line=line_number,
794
+ end_line=_declaration_end_line(source.splitlines(), line_number),
795
+ parent=parent,
796
+ parser="javascript-declaration",
797
+ ))
798
+ else:
799
+ for kind, pattern in DECLARATION_PATTERNS["javascript"][1:]:
800
+ match = re.search(pattern, line)
801
+ if match:
802
+ name = match.group(1)
803
+ symbols.append(Symbol(
804
+ name=name,
805
+ qualified_name=name,
806
+ kind=kind,
807
+ start_line=line_number,
808
+ end_line=_declaration_end_line(source.splitlines(), line_number),
809
+ parent=None,
810
+ parser="javascript-declaration",
811
+ ))
812
+ break
813
+ old_depth = brace_depth
814
+ brace_depth += line.count("{") - line.count("}")
815
+ if pending_class and brace_depth > old_depth:
816
+ class_stack.append((pending_class, brace_depth))
817
+ return symbols, None
818
+
819
+
820
+ def _deduplicate_scopes(symbols: list[Symbol]) -> list[Symbol]:
821
+ seen: set[str] = set()
822
+ result: list[Symbol] = []
823
+ for symbol in symbols:
824
+ qualified_name = symbol.qualified_name
825
+ if qualified_name in seen:
826
+ line_suffix = f"@L{symbol.start_line}"
827
+ candidate = f"{qualified_name}{line_suffix}"
828
+ if candidate in seen:
829
+ if symbol.start_byte is None:
830
+ candidate = f"{qualified_name}#2{line_suffix}"
831
+ else:
832
+ candidate = f"{qualified_name}@B{symbol.start_byte}{line_suffix}"
833
+ ordinal = 2
834
+ while candidate in seen:
835
+ if symbol.start_byte is None:
836
+ candidate = f"{qualified_name}#{ordinal}{line_suffix}"
837
+ else:
838
+ candidate = (
839
+ f"{qualified_name}#{ordinal}@B{symbol.start_byte}{line_suffix}"
840
+ )
841
+ ordinal += 1
842
+ symbol = replace(
843
+ symbol,
844
+ qualified_name=candidate,
845
+ )
846
+ seen.add(symbol.qualified_name)
847
+ result.append(symbol)
848
+ return result
849
+
850
+
851
+ def _merge_parser_symbols(primary: list[Symbol], fallback: list[Symbol]) -> list[Symbol]:
852
+ """补上增强解析器漏掉的声明,同时保留其精确范围和父子关系。"""
853
+ merged = list(primary)
854
+ seen = {(symbol.name, symbol.start_line) for symbol in primary}
855
+ for symbol in fallback:
856
+ key = (symbol.name, symbol.start_line)
857
+ if key not in seen:
858
+ merged.append(symbol)
859
+ seen.add(key)
860
+ return sorted(
861
+ merged,
862
+ key=lambda symbol: (symbol.start_line, symbol.end_line, symbol.qualified_name),
863
+ )
864
+
865
+
866
+ def parse_file(
867
+ path: Path, backend: str = "auto", *, cache: SourceContentCache | None = None,
868
+ ) -> tuple[list[Symbol], str | None, str]:
869
+ language = _language_for(path)
870
+ try:
871
+ if cache is not None:
872
+ source = cache.read_text(path)
873
+ else:
874
+ source = path.read_text(encoding="utf-8", errors="replace")
875
+ except OSError as exc:
876
+ return [], f"无法读取: {exc}", language
877
+ if backend not in {"auto", "builtin", "tree-sitter"}:
878
+ return [], f"未知解析后端: {backend}", language
879
+ tree_language = TREE_SITTER_LANGUAGES.get(path.suffix.lower())
880
+ if language == "python":
881
+ symbols, error = _python_symbols(source)
882
+ elif backend in {"auto", "tree-sitter"} and tree_language:
883
+ symbols, error = _tree_sitter_symbols(source, tree_language)
884
+ fallback, _ = (
885
+ _javascript_symbols(source) if language == "javascript"
886
+ else _declaration_symbols(source, language)
887
+ )
888
+ if backend == "auto":
889
+ # Always merge the conservative scanner: tree-sitter currently
890
+ # does not expose top-level variable/arrow declarations uniformly.
891
+ # A syntax error remains visible even when a fallback declaration
892
+ # was recovered; otherwise strict mode would claim false coverage.
893
+ symbols = _merge_parser_symbols(symbols, fallback)
894
+ if error and ("未安装" in error or "无法加载" in error):
895
+ error = None
896
+ elif language == "javascript":
897
+ symbols, error = _javascript_symbols(source)
898
+ else:
899
+ symbols, error = _declaration_symbols(source, language)
900
+ return _deduplicate_scopes(symbols), error, language
901
+
902
+
903
+ def _leaf_symbols(symbols: list[Symbol]) -> list[Symbol]:
904
+ parents = {symbol.parent for symbol in symbols if symbol.parent}
905
+ callable_names = {
906
+ symbol.qualified_name for symbol in symbols
907
+ if symbol.kind in {"function", "method", "async-function", "async-method"}
908
+ }
909
+
910
+ def nested_in_callable(symbol: Symbol) -> bool:
911
+ parent = symbol.parent
912
+ while parent:
913
+ if parent in callable_names:
914
+ return True
915
+ parent = parent.rsplit(".", 1)[0] if "." in parent else None
916
+ return False
917
+
918
+ return [
919
+ symbol for symbol in symbols
920
+ if not (symbol.kind in {"class", "type"} and symbol.qualified_name in parents)
921
+ and not nested_in_callable(symbol)
922
+ ]
923
+
924
+
925
+ def index_repository(
926
+ root: Path, backend: str = "auto", strict: bool = False,
927
+ *, cache: SourceContentCache | None = None,
928
+ ) -> dict:
929
+ root = root.resolve()
930
+ cache = cache if cache is not None else SourceContentCache()
931
+ files: list[dict] = []
932
+ nodes: list[dict] = []
933
+ edges: list[dict] = []
934
+ for path in discover_source_paths(root, strict=strict):
935
+ relative = path.relative_to(root).as_posix()
936
+ symbols, error, language = parse_file(path, backend, cache=cache)
937
+ try:
938
+ digest = file_sha256(path, cache)
939
+ size = path.stat().st_size
940
+ except OSError as exc:
941
+ if strict:
942
+ raise SourceDiscoveryError(f"源码读取失败 {path}: {exc}") from exc
943
+ # 宽松模式必须让读失败在索引输出层可区分(F-RSI-20261115-284):
944
+ # digest_status 与 parse 的 error 字段正交,二者可在同一文件共存,
945
+ # 避免"空 digest 文件"静默从索引消失、下游产生盲区。模式对齐
946
+ # code_analyzer._analyze_python_ast 的 parse_status(F-RSI-20261115-276)。
947
+ digest = ""
948
+ size = 0
949
+ digest_status = "error"
950
+ else:
951
+ digest_status = "ok"
952
+ file_id = f"file:{relative}"
953
+ nodes.append({"id": file_id, "type": "file", "path": relative})
954
+ symbol_payload = []
955
+ for symbol in symbols:
956
+ item = asdict(symbol)
957
+ # Byte offsets are an internal stable disambiguator for colliding
958
+ # AST scopes; they are not part of the public index payload schema.
959
+ item.pop("start_byte", None)
960
+ item["scope"] = f"{relative}::{symbol.scope_name}"
961
+ symbol_payload.append(item)
962
+ symbol_id = f"symbol:{relative}::{symbol.qualified_name}"
963
+ nodes.append({"id": symbol_id, "type": "symbol", "path": relative, **item})
964
+ parent_id = (
965
+ f"symbol:{relative}::{symbol.parent}" if symbol.parent else file_id
966
+ )
967
+ edges.append({"type": "contains", "from": parent_id, "to": symbol_id})
968
+ files.append({
969
+ "path": relative,
970
+ "language": language,
971
+ "parser": symbols[0].parser if symbols else (
972
+ "python-ast" if language == "python" else f"{language}-declaration"
973
+ ),
974
+ "error": error,
975
+ "content_hash": digest,
976
+ "size": size,
977
+ "digest_status": digest_status,
978
+ "symbols": symbol_payload,
979
+ })
980
+ return {
981
+ "schema_version": SCHEMA_VERSION,
982
+ "root": ".",
983
+ "files": files,
984
+ "nodes": nodes,
985
+ "edges": edges,
986
+ "summary": {
987
+ "files": len(files),
988
+ "symbols": sum(len(item["symbols"]) for item in files),
989
+ "parse_errors": sum(bool(item["error"]) for item in files),
990
+ "digest_errors": sum(
991
+ 1 for item in files if item["digest_status"] == "error"
992
+ ),
993
+ },
994
+ }
995
+
996
+
997
+ def audit_units(
998
+ root: Path, backend: str = "auto", strict: bool = False,
999
+ *, cache: SourceContentCache | None = None,
1000
+ ) -> list[dict]:
1001
+ """返回最细审计单元;有符号时取叶子符号,否则退回文件。"""
1002
+ root = root.resolve()
1003
+ cache = cache if cache is not None else SourceContentCache()
1004
+ result: list[dict] = []
1005
+ for path in discover_source_paths(root, strict=strict):
1006
+ relative = path.relative_to(root).as_posix()
1007
+ symbols, error, language = parse_file(path, backend, cache=cache)
1008
+ try:
1009
+ digest = file_sha256(path, cache)
1010
+ except OSError as exc:
1011
+ if strict:
1012
+ raise SourceDiscoveryError(f"源码读取失败 {path}: {exc}") from exc
1013
+ digest = ""
1014
+ # F-RSI-20261115-284 同型输出面:与 index_repository 的 digest_status
1015
+ # 对齐,避免读失败单元以空 content_hash 静默进入下游审计/覆盖清单。
1016
+ digest_status = "error"
1017
+ else:
1018
+ digest_status = "ok"
1019
+ leaves = _leaf_symbols(symbols)
1020
+ if leaves and all(symbol.kind == "module" for symbol in leaves):
1021
+ # A file containing only constants/configuration remains a useful
1022
+ # file-level task; do not manufacture a synthetic callable task.
1023
+ leaves = []
1024
+ if leaves:
1025
+ result.extend({
1026
+ "scope": f"{relative}::{symbol.scope_name}",
1027
+ "path": relative,
1028
+ "name": symbol.name,
1029
+ "kind": symbol.kind,
1030
+ "line": symbol.start_line,
1031
+ "parser": symbol.parser,
1032
+ "error": error,
1033
+ "end_line": symbol.end_line,
1034
+ "content_hash": digest,
1035
+ "digest_status": digest_status,
1036
+ "language": language,
1037
+ } for symbol in leaves)
1038
+ else:
1039
+ result.append({
1040
+ "scope": relative,
1041
+ "path": relative,
1042
+ "name": path.stem,
1043
+ "kind": "file",
1044
+ "line": 1,
1045
+ "parser": "fallback-file",
1046
+ "error": error,
1047
+ "language": language,
1048
+ "content_hash": digest,
1049
+ "digest_status": digest_status,
1050
+ })
1051
+ return result
1052
+
1053
+
1054
+ def inventory_snapshot(
1055
+ root: Path, backend: str = "auto", strict: bool = False,
1056
+ *, cache: SourceContentCache | None = None,
1057
+ ) -> dict:
1058
+ """Return one hashable inventory for source and behavior-affecting assets."""
1059
+ root = root.resolve()
1060
+ cache = cache if cache is not None else SourceContentCache()
1061
+ source_paths = discover_source_paths(root, strict=strict)
1062
+ asset_paths = discover_asset_paths(root, strict=strict)
1063
+ records: list[dict] = []
1064
+ for path in source_paths:
1065
+ relative = path.relative_to(root).as_posix()
1066
+ symbols, error, language = parse_file(path, backend, cache=cache)
1067
+ records.append({
1068
+ "path": relative, "kind": "source", "language": language,
1069
+ "content_hash": file_sha256(path, cache), "parse_error": error,
1070
+ "scopes": [f"{relative}::{symbol.scope_name}" for symbol in symbols],
1071
+ })
1072
+ for path in asset_paths:
1073
+ records.append({
1074
+ "path": path.relative_to(root).as_posix(), "kind": "asset",
1075
+ "content_hash": file_sha256(path, cache),
1076
+ })
1077
+ records.sort(key=lambda item: (item["kind"], item["path"]))
1078
+ encoded = json.dumps(records, ensure_ascii=False, sort_keys=True).encode("utf-8")
1079
+ return {
1080
+ "schema_version": SCHEMA_VERSION,
1081
+ "files": records,
1082
+ "inventory_hash": hashlib.sha256(encoded).hexdigest(),
1083
+ }
1084
+
1085
+
1086
+ def main(argv: list[str] | None = None) -> int:
1087
+ parser = argparse.ArgumentParser(description=__doc__)
1088
+ parser.add_argument(
1089
+ "command", choices=("scan", "units", "inventory"), nargs="?", default="scan",
1090
+ )
1091
+ parser.add_argument("--root", type=Path, default=Path.cwd())
1092
+ parser.add_argument("--json", action="store_true")
1093
+ parser.add_argument("--strict", action="store_true",
1094
+ help="任一文件解析失败时返回非零")
1095
+ parser.add_argument("--backend", choices=("auto", "builtin", "tree-sitter"),
1096
+ default="auto")
1097
+ args = parser.parse_args(argv)
1098
+ if args.command == "inventory":
1099
+ try:
1100
+ payload = inventory_snapshot(args.root, args.backend, strict=args.strict)
1101
+ except SourceDiscoveryError as exc:
1102
+ print(f"[symbol_index] ✗ {exc}", file=sys.stderr)
1103
+ return 2
1104
+ except OSError as exc:
1105
+ print(f"[symbol_index] ✗ 项目清单读取失败: {exc}", file=sys.stderr)
1106
+ return 2
1107
+ if args.json:
1108
+ print(json.dumps(payload, ensure_ascii=False, indent=2))
1109
+ else:
1110
+ print(f"[symbol_index] 清单文件 {len(payload['files'])},"
1111
+ f"inventory_hash={payload['inventory_hash']}")
1112
+ parse_errors = [item for item in payload["files"] if item.get("parse_error")]
1113
+ return 1 if args.strict and parse_errors else 0
1114
+ if args.command == "units":
1115
+ try:
1116
+ units = audit_units(args.root, args.backend, strict=args.strict)
1117
+ except SourceDiscoveryError as exc:
1118
+ print(f"[symbol_index] ✗ {exc}", file=sys.stderr)
1119
+ return 2
1120
+ if args.json:
1121
+ print(json.dumps({"schema_version": SCHEMA_VERSION, "units": units},
1122
+ ensure_ascii=False, indent=2))
1123
+ else:
1124
+ for unit in units:
1125
+ print(f"{unit['scope']}\t{unit['kind']}\tline {unit['line']}")
1126
+ parse_errors = sum(bool(unit.get("error")) for unit in units)
1127
+ if args.strict and parse_errors:
1128
+ return 1
1129
+ return 0 if units else 1
1130
+ try:
1131
+ payload = index_repository(args.root, args.backend, strict=args.strict)
1132
+ except SourceDiscoveryError as exc:
1133
+ print(f"[symbol_index] ✗ {exc}", file=sys.stderr)
1134
+ return 2
1135
+ if args.json:
1136
+ print(json.dumps(payload, ensure_ascii=False, indent=2))
1137
+ else:
1138
+ summary = payload["summary"]
1139
+ print(f"[symbol_index] 文件 {summary['files']},符号 {summary['symbols']},"
1140
+ f"解析错误 {summary['parse_errors']}")
1141
+ for item in payload["files"]:
1142
+ status = (
1143
+ f"ERROR: {item['error']}" if item["error"]
1144
+ else f"{len(item['symbols'])} symbols"
1145
+ )
1146
+ print(f" {item['path']}: {status}")
1147
+ return 1 if args.strict and payload["summary"]["parse_errors"] else 0
1148
+
1149
+
1150
+ if __name__ == "__main__":
1151
+ sys.exit(main())