branchpy-cli 1.1.19__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.
- bqf/__init__.py +16 -0
- bqf/registry.py +208 -0
- branchpy/__init__.py +29 -0
- branchpy/__main__.py +4 -0
- branchpy/ai/__init__.py +49 -0
- branchpy/ai/ai_models.py +65 -0
- branchpy/ai/ai_routing.py +119 -0
- branchpy/ai/ai_tasks.py +165 -0
- branchpy/ai/ast_integration/__init__.py +28 -0
- branchpy/ai/ast_integration/ast_context.py +471 -0
- branchpy/ai/ast_integration/code_review.py +368 -0
- branchpy/ai/ast_integration/explain_warning.py +428 -0
- branchpy/ai/ast_integration/refactor_suggester.py +413 -0
- branchpy/ai/config.py +203 -0
- branchpy/ai/data_guard.py +147 -0
- branchpy/ai/models.py +205 -0
- branchpy/ai/protocol.py +173 -0
- branchpy/ai/provider_base.py +59 -0
- branchpy/ai/provider_manager.py +105 -0
- branchpy/ai/provider_registry.py +117 -0
- branchpy/ai/providers/__init__.py +13 -0
- branchpy/ai/providers/anthropic_provider.py +309 -0
- branchpy/ai/providers/gemini_provider.py +177 -0
- branchpy/ai/providers/http_provider.py +214 -0
- branchpy/ai/providers/ollama_provider.py +453 -0
- branchpy/ai/providers/openai_provider.py +328 -0
- branchpy/ai/providers/venice_provider.py +423 -0
- branchpy/ai/request_models.py +38 -0
- branchpy/ai/safety/__init__.py +71 -0
- branchpy/ai/safety/consent.py +425 -0
- branchpy/ai/safety/governance.py +500 -0
- branchpy/ai/safety/middleware.py +389 -0
- branchpy/ai/safety/policy.py +410 -0
- branchpy/ai/safety/provider_validator.py +162 -0
- branchpy/ai/safety/redaction.py +345 -0
- branchpy/ai/safety/redaction_config.py +157 -0
- branchpy/ai/safety/safe_mode.py +215 -0
- branchpy/ai/safety/safe_mode_config.py +160 -0
- branchpy/ai/service.py +238 -0
- branchpy/ai/telemetry.py +81 -0
- branchpy/analysis/__init__.py +5 -0
- branchpy/analysis/catalog.py +20 -0
- branchpy/analysis/flow_graph_analysis.py +2831 -0
- branchpy/analysis/group_types.py +156 -0
- branchpy/analysis/image_validation/__init__.py +28 -0
- branchpy/analysis/image_validation/backends/__init__.py +52 -0
- branchpy/analysis/image_validation/backends/clip_backend.py +186 -0
- branchpy/analysis/image_validation/backends/phash_backend.py +248 -0
- branchpy/analysis/image_validation/benchmarks/README.md +145 -0
- branchpy/analysis/image_validation/benchmarks/__init__.py +99 -0
- branchpy/analysis/image_validation/benchmarks/benchmark_cache.py +134 -0
- branchpy/analysis/image_validation/benchmarks/benchmark_clip.py +92 -0
- branchpy/analysis/image_validation/benchmarks/benchmark_e2e.py +130 -0
- branchpy/analysis/image_validation/benchmarks/benchmark_phash.py +74 -0
- branchpy/analysis/image_validation/cache/__init__.py +8 -0
- branchpy/analysis/image_validation/cache/feature_store.py +258 -0
- branchpy/analysis/image_validation/clustering.py +231 -0
- branchpy/analysis/image_validation/config.py +115 -0
- branchpy/analysis/image_validation/embedding_cache.py +196 -0
- branchpy/analysis/image_validation/governance_logger.py +932 -0
- branchpy/analysis/image_validation/hasher.py +161 -0
- branchpy/analysis/image_validation/history.py +275 -0
- branchpy/analysis/image_validation/models.py +116 -0
- branchpy/analysis/image_validation/performance.slo +41 -0
- branchpy/analysis/image_validation/policies_bqf.py +46 -0
- branchpy/analysis/image_validation/preprocess.py +312 -0
- branchpy/analysis/image_validation/provider_policy.py +174 -0
- branchpy/analysis/image_validation/providers_v2/__init__.py +53 -0
- branchpy/analysis/image_validation/providers_v2/base.py +442 -0
- branchpy/analysis/image_validation/providers_v2/dropbox.py +355 -0
- branchpy/analysis/image_validation/providers_v2/errors.py +191 -0
- branchpy/analysis/image_validation/providers_v2/gdrive.py +784 -0
- branchpy/analysis/image_validation/providers_v2/github.py +256 -0
- branchpy/analysis/image_validation/providers_v2/mfiles.py +88 -0
- branchpy/analysis/image_validation/providers_v2/onedrive.py +565 -0
- branchpy/analysis/image_validation/providers_v2/registry.py +210 -0
- branchpy/analysis/image_validation/providers_v2/sync.py +290 -0
- branchpy/analysis/image_validation/providers_v2/thumbnails.py +249 -0
- branchpy/analysis/image_validation/providers_v2/util.py +273 -0
- branchpy/analysis/image_validation/providers_v2/vault.py +857 -0
- branchpy/analysis/image_validation/providers_v2/webdav.py +255 -0
- branchpy/analysis/image_validation/scanner.py +178 -0
- branchpy/analysis/image_validation/semantic/__init__.py +9 -0
- branchpy/analysis/image_validation/semantic/linker.py +346 -0
- branchpy/analysis/image_validation/semantic/nodes.py +220 -0
- branchpy/analysis/image_validation/similarity.py +227 -0
- branchpy/analysis/image_validation/tests/__init__.py +10 -0
- branchpy/analysis/image_validation/tests/run_tests.py +22 -0
- branchpy/analysis/image_validation/tests/test_feature_store.py +174 -0
- branchpy/analysis/image_validation/tests/test_integration.py +118 -0
- branchpy/analysis/image_validation/tests/test_phash_backend.py +121 -0
- branchpy/analysis/image_validation/tests/test_scanner.py +137 -0
- branchpy/analysis/image_validation/tests/test_semantic_linker.py +147 -0
- branchpy/analysis/image_validation/tests/test_semantic_nodes.py +232 -0
- branchpy/analysis/image_validation/v3/__init__.py +30 -0
- branchpy/analysis/image_validation/v3/cache_manager.py +290 -0
- branchpy/analysis/image_validation/v3/cluster_engine.py +253 -0
- branchpy/analysis/image_validation/validator.py +759 -0
- branchpy/analysis/observed/trace_ingestor.py +323 -0
- branchpy/analysis/omega.py +330 -0
- branchpy/analysis/pfi/__init__.py +56 -0
- branchpy/analysis/pfi/call_graph.py +217 -0
- branchpy/analysis/pfi/call_site_analyzer.py +465 -0
- branchpy/analysis/pfi/consistency_checker.py +440 -0
- branchpy/analysis/pfi/enhanced_analyzer.py +461 -0
- branchpy/analysis/pfi/exporter.py +176 -0
- branchpy/analysis/pfi/function_indexer.py +673 -0
- branchpy/analysis/pfi/governance.py +416 -0
- branchpy/analysis/pfi/stat_effect_analyzer.py +521 -0
- branchpy/analysis/sae/__init__.py +31 -0
- branchpy/analysis/sae/assets/__init__.py +64 -0
- branchpy/analysis/sae/assets/asset_scanner.py +301 -0
- branchpy/analysis/sae/assets/csv_export.py +361 -0
- branchpy/analysis/sae/assets/definition_extractor.py +160 -0
- branchpy/analysis/sae/assets/dimension_validator.py +370 -0
- branchpy/analysis/sae/assets/fuzzy.py +168 -0
- branchpy/analysis/sae/assets/governance.py +289 -0
- branchpy/analysis/sae/assets/models.py +166 -0
- branchpy/analysis/sae/assets/reference_extractor.py +271 -0
- branchpy/analysis/sae/assets/similarity.py +403 -0
- branchpy/analysis/sae/assets/sync_provider.py +471 -0
- branchpy/analysis/sae/assets/validators/__init__.py +1 -0
- branchpy/analysis/sae/assets/validators/assets_format_validator.py +258 -0
- branchpy/analysis/sae/assets/validators/assets_fuzzy_typo_validator.py +132 -0
- branchpy/analysis/sae/assets/validators/assets_missing_validator.py +194 -0
- branchpy/analysis/sae/assets/validators/assets_unused_validator.py +179 -0
- branchpy/analysis/sae/assignment_extractor.py +1220 -0
- branchpy/analysis/sae/cfg_builder.py +1221 -0
- branchpy/analysis/sae/config_schema.py +499 -0
- branchpy/analysis/sae/custom_rule_loader.py +269 -0
- branchpy/analysis/sae/custom_rule_registry.py +304 -0
- branchpy/analysis/sae/dataflow.py +281 -0
- branchpy/analysis/sae/exporters/__init__.py +5 -0
- branchpy/analysis/sae/exporters/flowgraph.py +99 -0
- branchpy/analysis/sae/exporters/unified_report.py +248 -0
- branchpy/analysis/sae/finding_adapter.py +83 -0
- branchpy/analysis/sae/finding_postprocess.py +241 -0
- branchpy/analysis/sae/graphs/__init__.py +14 -0
- branchpy/analysis/sae/graphs/variable_graph.py +259 -0
- branchpy/analysis/sae/image_validator.py +346 -0
- branchpy/analysis/sae/indexer.py +1043 -0
- branchpy/analysis/sae/job.py +268 -0
- branchpy/analysis/sae/locale_parser.py +267 -0
- branchpy/analysis/sae/project_policy.py +326 -0
- branchpy/analysis/sae/registry.py +63 -0
- branchpy/analysis/sae/renderers/html_assets_section.py +100 -0
- branchpy/analysis/sae/report_v1.py +93 -0
- branchpy/analysis/sae/schemas/analyze_report_v1.json +225 -0
- branchpy/analysis/sae/schemas/assets_report.json +161 -0
- branchpy/analysis/sae/schemas/flowgraph.json +134 -0
- branchpy/analysis/sae/schemas/job.json +118 -0
- branchpy/analysis/sae/schemas/unified_report.json +213 -0
- branchpy/analysis/sae/screen_return_resolver.py +758 -0
- branchpy/analysis/sae/semantics.py +218 -0
- branchpy/analysis/sae/statement_extractor.py +1107 -0
- branchpy/analysis/sae/validators/__init__.py +5 -0
- branchpy/analysis/sae/validators/dialogue_validator.py +839 -0
- branchpy/analysis/sae/validators/locale_validator.py +306 -0
- branchpy/analysis/sae/validators/menu_fallthrough_validator.py +318 -0
- branchpy/analysis/sae/validators/screen_action_validator.py +68 -0
- branchpy/analysis/sae/validators/tier1.py +783 -0
- branchpy/analysis/sae/validators/variable_analyzer.py +909 -0
- branchpy/analysis/sae/variable_usage_extractor.py +405 -0
- branchpy/analysis/sae/worker.py +535 -0
- branchpy/analysis/semantic_edges.py +743 -0
- branchpy/analysis/semantic_grouping.py +721 -0
- branchpy/analysis/stats2/__init__.py +46 -0
- branchpy/analysis/stats2/aggregator.py +516 -0
- branchpy/analysis/stats2/assignment_extractor.py +207 -0
- branchpy/analysis/stats2/compute.py +161 -0
- branchpy/analysis/stats2/exporter.py +301 -0
- branchpy/analysis/stats2/expr_evaluator.py +160 -0
- branchpy/analysis/stats2/expr_parser.py +250 -0
- branchpy/analysis/stats2/narrative_paths.py +1599 -0
- branchpy/analysis/stats2/path_stats.py +817 -0
- branchpy/analysis/stats2/ranges.py +141 -0
- branchpy/analysis/stats2/registry.py +72 -0
- branchpy/analysis/variable_flow.py +589 -0
- branchpy/analyze/engines/generic_media.py +348 -0
- branchpy/analyze/engines/godot_media.py +451 -0
- branchpy/analyze/engines/renpy_media.py +705 -0
- branchpy/analyze/engines/unity_media.py +447 -0
- branchpy/analyze/media_adapters/__init__.py +164 -0
- branchpy/analyze/media_adapters/generic_media.py +125 -0
- branchpy/analyze/media_adapters/godot_media.py +141 -0
- branchpy/analyze/media_adapters/renpy_phase_c_adapter.py +286 -0
- branchpy/analyze/media_adapters/unity_media.py +159 -0
- branchpy/analyze/media_adapters.py +286 -0
- branchpy/analyze/media_export.py +441 -0
- branchpy/analyze/media_phase_c_contract.py +372 -0
- branchpy/analyze/media_validate.py +333 -0
- branchpy/analyze/pfi/__init__.py +9 -0
- branchpy/analyze/pfi/media_inference.py +211 -0
- branchpy/analyze/pfi/media_inference_scaffold.py +383 -0
- branchpy/analyzer/ast_to_scriptgraph.py +151 -0
- branchpy/analyzer/flow_delta.py +385 -0
- branchpy/analyzer/media_indexer.py +235 -0
- branchpy/analyzer/merge_risk_analyzer.py +404 -0
- branchpy/analyzer/narrative_impact.py +414 -0
- branchpy/analyzer/parser.py +212 -0
- branchpy/analyzer/pfi_expressions.py +524 -0
- branchpy/analyzer/pfi_inference.py +730 -0
- branchpy/analyzer/providers.py +289 -0
- branchpy/analyzer/remote_context.py +136 -0
- branchpy/analyzer/remote_paths.py +278 -0
- branchpy/analyzer/script_graph.py +777 -0
- branchpy/analyzers/scene_coverage_analyzer_telemetry_example.py +294 -0
- branchpy/artifact_freshness.py +200 -0
- branchpy/attribution.py +123 -0
- branchpy/audit/verify_commit.py +35 -0
- branchpy/auto_detect/__init__.py +40 -0
- branchpy/auto_detect/events.py +344 -0
- branchpy/auto_detect/pattern_miner.py +730 -0
- branchpy/auto_detect/policy_scaffolder.py +637 -0
- branchpy/auto_detect/recommendation_engine.py +463 -0
- branchpy/auto_detect/rule_inference.py +613 -0
- branchpy/benchmarks/suite.py +327 -0
- branchpy/bootstrap.py +20 -0
- branchpy/bqf/__init__.py +19 -0
- branchpy/bqf/context_mapping.py +128 -0
- branchpy/bqf/models_ai.py +24 -0
- branchpy/bqf/policies/__init__.py +33 -0
- branchpy/bqf/policies/compare/__init__.py +5 -0
- branchpy/bqf/policies/compare/similarity_floor.py +162 -0
- branchpy/bqf/policies/media/__init__.py +6 -0
- branchpy/bqf/policies/media/checksum_verified.py +185 -0
- branchpy/bqf/policies/media/duplicate_cap.py +160 -0
- branchpy/bqf/policies/media_policies.py +320 -0
- branchpy/bqf/policies_ai.py +144 -0
- branchpy/bqf/policy_base.py +302 -0
- branchpy/bqf/policy_config.example.toml +30 -0
- branchpy/bqf/policy_config.example.yaml +38 -0
- branchpy/bqf/policy_enforcer.py +487 -0
- branchpy/bqf/registry.py +237 -0
- branchpy/bqf/rules/missing_media_reference.json +67 -0
- branchpy/bqf/rules/unused_media_file.json +69 -0
- branchpy/bqf/runner.py +182 -0
- branchpy/bqf/runner_ai.py +167 -0
- branchpy/bqf/semantic_policy.py +325 -0
- branchpy/cache/__init__.py +52 -0
- branchpy/cache/backends/__init__.py +20 -0
- branchpy/cache/backends/base.py +148 -0
- branchpy/cache/backends/memory.py +229 -0
- branchpy/cache/backends/redis.py +309 -0
- branchpy/cache/backends/sqlite.py +292 -0
- branchpy/cache/decorators.py +266 -0
- branchpy/cache/keys.py +92 -0
- branchpy/cache/manager.py +281 -0
- branchpy/cfg_viewer/__init__.py +19 -0
- branchpy/cfg_viewer/cfg_collapse.py +463 -0
- branchpy/cfg_viewer/cfg_exporter.py +196 -0
- branchpy/cfg_viewer/cfg_to_graphviz.py +294 -0
- branchpy/choice_analyzer.py +286 -0
- branchpy/cli/__init__.py +40 -0
- branchpy/cli/__main__.py +41 -0
- branchpy/cli/ai_cli.py +426 -0
- branchpy/cli/ai_cmd.py +382 -0
- branchpy/cli/audit_cmd.py +316 -0
- branchpy/cli/audit_diff_cmd.py +75 -0
- branchpy/cli/cloud_cli.py +220 -0
- branchpy/cli/commands/__init__.py +8 -0
- branchpy/cli/commands/ai_cmd.py +388 -0
- branchpy/cli/commands/ai_patch_cmd.py +479 -0
- branchpy/cli/commands/ai_report_cmd.py +249 -0
- branchpy/cli/commands/auto_detect_cmd.py +410 -0
- branchpy/cli/commands/bqf_rules_cmd.py +455 -0
- branchpy/cli/commands/export_media_cmd.py +169 -0
- branchpy/cli/commands/federation_cmd.py +297 -0
- branchpy/cli/commands/identity_hub_cmd.py +210 -0
- branchpy/cli/commands/journal_cmd.py +59 -0
- branchpy/cli/commands/l10n_audit_cmd.py +957 -0
- branchpy/cli/commands/l10n_trend_cmd.py +771 -0
- branchpy/cli/commands/license_cmd.py +741 -0
- branchpy/cli/commands/merge_cmd.py +273 -0
- branchpy/cli/commands/patch_cmd.py +586 -0
- branchpy/cli/commands/projects_hub_cmd.py +229 -0
- branchpy/cli/commands/redo_cmd.py +59 -0
- branchpy/cli/commands/semantics_v2_cmd.py +1715 -0
- branchpy/cli/commands/stats_policies_cmd.py +492 -0
- branchpy/cli/commands/telemetry_sync.py +178 -0
- branchpy/cli/commands/templates_cmd.py +427 -0
- branchpy/cli/commands/undo_cmd.py +62 -0
- branchpy/cli/commands/ws_cmd.py +326 -0
- branchpy/cli/coverage_cmd_minimal.py +282 -0
- branchpy/cli/debug_cmd.py +70 -0
- branchpy/cli/hooks_cmd.py +30 -0
- branchpy/cli/html_report.py +3461 -0
- branchpy/cli/identity_cmd.py +117 -0
- branchpy/cli/l10n_cmd.py +337 -0
- branchpy/cli/migrate_cmd.py +217 -0
- branchpy/cli/policy_cmd.py +377 -0
- branchpy/cli/rule_versioning_cli.py +446 -0
- branchpy/cli/rules_cmd.py +198 -0
- branchpy/cli/sae_cmd.py +141 -0
- branchpy/cli/serve_cmd.py +34 -0
- branchpy/cli/server_cmd.py +352 -0
- branchpy/cli/team_cmd.py +282 -0
- branchpy/cli/telemetry_cmd.py +2462 -0
- branchpy/cli/test_cli.py +170 -0
- branchpy/cli.py +1898 -0
- branchpy/cli_help.py +16 -0
- branchpy/cli_update.py +42 -0
- branchpy/cloud/mock_env.py +186 -0
- branchpy/commands/__init__.py +0 -0
- branchpy/commands/ai_cmd.py +532 -0
- branchpy/commands/analyze_cmd.py +1890 -0
- branchpy/commands/analyzer_media_cmd.py +179 -0
- branchpy/commands/audit_cmd.py +342 -0
- branchpy/commands/bootstrap_cmd.py +121 -0
- branchpy/commands/cmd_activate.py +28 -0
- branchpy/commands/cmd_deactivate.py +37 -0
- branchpy/commands/cmd_status.py +32 -0
- branchpy/commands/cmd_test.py +365 -0
- branchpy/commands/compare_cmd.py +443 -0
- branchpy/commands/compare_preview_cmd.py +407 -0
- branchpy/commands/config_cmd.py +343 -0
- branchpy/commands/dev_cmd.py +263 -0
- branchpy/commands/doctor_cmd.py +2189 -0
- branchpy/commands/doctor_cmd_old.py +561 -0
- branchpy/commands/enhanced_report.py +274 -0
- branchpy/commands/flowchart_cmd.py +181 -0
- branchpy/commands/guard_cmd.py +430 -0
- branchpy/commands/help_cmd.py +169 -0
- branchpy/commands/helpers.py +33 -0
- branchpy/commands/history_cmd.py +897 -0
- branchpy/commands/identity_cmd.py +192 -0
- branchpy/commands/image_semantic_cmd.py +386 -0
- branchpy/commands/image_validate_cmd.py +806 -0
- branchpy/commands/insights_cmd.py +443 -0
- branchpy/commands/interactive_diff_cmd.py +102 -0
- branchpy/commands/l10n_cmd.py +268 -0
- branchpy/commands/logs_cmd.py +249 -0
- branchpy/commands/media.py +139 -0
- branchpy/commands/media_cmd.py +1454 -0
- branchpy/commands/media_v3_cmd.py +605 -0
- branchpy/commands/migrate_cmd.py +229 -0
- branchpy/commands/omega_cmd.py +335 -0
- branchpy/commands/patch_state.py +41 -0
- branchpy/commands/patches_cmd.py +195 -0
- branchpy/commands/pfi_cmd.py +266 -0
- branchpy/commands/policy_cmd.py +258 -0
- branchpy/commands/project_resolver.py +76 -0
- branchpy/commands/projects_cmd.py +124 -0
- branchpy/commands/provider_cmd.py +740 -0
- branchpy/commands/provider_v3_cmd.py +556 -0
- branchpy/commands/redo_cmd.py +95 -0
- branchpy/commands/renpy_cmd.py +357 -0
- branchpy/commands/report_cmd.py +197 -0
- branchpy/commands/semantics_cmd.py +305 -0
- branchpy/commands/semantics_engine_cmd.py +263 -0
- branchpy/commands/serve_cmd.py +741 -0
- branchpy/commands/stats2_cmd.py +931 -0
- branchpy/commands/stats_cmd.py +1517 -0
- branchpy/commands/support_cmd.py +97 -0
- branchpy/commands/tests_cmd.py +418 -0
- branchpy/commands/trace_cmd.py +518 -0
- branchpy/commands/undo_cmd.py +95 -0
- branchpy/commands/uninstall_cmd.py +230 -0
- branchpy/commands/validate_cmd.py +219 -0
- branchpy/commands/watch_cmd.py +129 -0
- branchpy/commands/welcome_cmd.py +482 -0
- branchpy/compare/analyzer.py +202 -0
- branchpy/compare/compare_media_integration.py +143 -0
- branchpy/compare/constants.py +70 -0
- branchpy/compare/media_diff_engine.py +331 -0
- branchpy/compare/media_diff_types.py +118 -0
- branchpy/completeness_checker.py +363 -0
- branchpy/config.py +235 -0
- branchpy/config_store.py +322 -0
- branchpy/contract.py +37 -0
- branchpy/core/__init__.py +25 -0
- branchpy/core/audit.py +791 -0
- branchpy/core/cfg.py +90 -0
- branchpy/core/compare/__init__.py +42 -0
- branchpy/core/compare/alignment.py +296 -0
- branchpy/core/compare/anchors.py +229 -0
- branchpy/core/compare/exporter.py +458 -0
- branchpy/core/compare/guard_normalizer.py +157 -0
- branchpy/core/compare/pfi_integration.py +339 -0
- branchpy/core/compare/preview_engine.py +241 -0
- branchpy/core/compare/row_emitter.py +217 -0
- branchpy/core/compare/semantic_types.py +204 -0
- branchpy/core/compare/tape_builder.py +264 -0
- branchpy/core/config.py +19 -0
- branchpy/core/crash_report.py +15 -0
- branchpy/core/diffing.py +220 -0
- branchpy/core/engine_interface.py +34 -0
- branchpy/core/engine_resolver.py +406 -0
- branchpy/core/fs.py +43 -0
- branchpy/core/governance/README.md +475 -0
- branchpy/core/governance/__init__.py +46 -0
- branchpy/core/governance/__main__.py +156 -0
- branchpy/core/governance/audit_exporter.py +340 -0
- branchpy/core/governance/audit_hooks.py +210 -0
- branchpy/core/governance/benchmark_decorator_overhead.py +147 -0
- branchpy/core/governance/certificates.py +242 -0
- branchpy/core/governance/denial_history.py +461 -0
- branchpy/core/governance/denial_suggestions.py +311 -0
- branchpy/core/governance/guards.py +332 -0
- branchpy/core/governance/integrity.py +221 -0
- branchpy/core/governance/logger.py +471 -0
- branchpy/core/governance/policy_engine.py +305 -0
- branchpy/core/governance/schemas.py +217 -0
- branchpy/core/governance/standard_command_enforcement.py +276 -0
- branchpy/core/governance/team_manager.py +171 -0
- branchpy/core/history/README.md +217 -0
- branchpy/core/history/__init__.py +150 -0
- branchpy/core/history/compression.py +436 -0
- branchpy/core/history/consolidation_daemon.py +627 -0
- branchpy/core/history/delta_reconstructor.py +672 -0
- branchpy/core/history/diff_engine.py +637 -0
- branchpy/core/history/diff_export.py +938 -0
- branchpy/core/history/governance_bridge.py +473 -0
- branchpy/core/history/governance_diff.py +675 -0
- branchpy/core/history/merge_engine.py +791 -0
- branchpy/core/history/persistence.py +483 -0
- branchpy/core/history/sample_config.json +32 -0
- branchpy/core/history/sample_governance_event.json +22 -0
- branchpy/core/history/sample_history.jsonl +5 -0
- branchpy/core/history/sample_snapshot.json +144 -0
- branchpy/core/history/snapshot.py +834 -0
- branchpy/core/history/snapshot_optimizer.py +518 -0
- branchpy/core/history/stack.py +408 -0
- branchpy/core/history/timeline.py +484 -0
- branchpy/core/jsonio.py +40 -0
- branchpy/core/patches.py +442 -0
- branchpy/core/paths.py +18 -0
- branchpy/core/paths_v2.py +371 -0
- branchpy/core/perf_profiler.py +255 -0
- branchpy/core/plugins.py +299 -0
- branchpy/core/project_model.py +48 -0
- branchpy/core/remote_context.py +428 -0
- branchpy/core/renderer.py +162 -0
- branchpy/core/reports.py +209 -0
- branchpy/core/semantics/__init__.py +49 -0
- branchpy/core/semantics/definitions.py +337 -0
- branchpy/core/semantics/function_provider.py +296 -0
- branchpy/core/semantics/migration.py +362 -0
- branchpy/core/semantics/registry.py +234 -0
- branchpy/core/semantics/semantic_action.py +130 -0
- branchpy/core/semantics/semantic_node.py +85 -0
- branchpy/core/semantics/trace_exporter.py +190 -0
- branchpy/core/snapshot.py +22 -0
- branchpy/core/telemetry.py +35 -0
- branchpy/credential_vault/legacy_shim.py +282 -0
- branchpy/credential_vault/migrate.py +348 -0
- branchpy/credential_vault/schema_v3.json +250 -0
- branchpy/credential_vault/vault_v2.py +384 -0
- branchpy/daemon/context.py +127 -0
- branchpy/daemon/routes_governance.py +482 -0
- branchpy/daemon/routes_history.py +1090 -0
- branchpy/daemon/routes_validation.py +350 -0
- branchpy/daemon/shutdown.py +47 -0
- branchpy/dashboard/websocket_server.py +348 -0
- branchpy/database.py +55 -0
- branchpy/discovery/__init__.py +31 -0
- branchpy/discovery/base.py +256 -0
- branchpy/discovery/cache.py +322 -0
- branchpy/discovery/detectors/__init__.py +13 -0
- branchpy/discovery/detectors/godot.py +18 -0
- branchpy/discovery/detectors/renpy.py +67 -0
- branchpy/discovery/detectors/unity.py +18 -0
- branchpy/discovery/detectors/unreal.py +18 -0
- branchpy/discovery/orchestrator.py +252 -0
- branchpy/discovery/tests/__init__.py +1 -0
- branchpy/discovery/tests/test_ambiguity_and_metadata.py +121 -0
- branchpy/discovery/tests/test_base.py +85 -0
- branchpy/discovery/tests/test_cache_correctness.py +232 -0
- branchpy/discovery/tests/test_cache_performance.py +143 -0
- branchpy/discovery/tests/test_orchestrator.py +98 -0
- branchpy/discovery/tests/test_override_policy.py +119 -0
- branchpy/discovery/tests/test_renpy_detector.py +131 -0
- branchpy/doctor/omega_artifacts.py +155 -0
- branchpy/emit.py +54 -0
- branchpy/engines/__init__.py +5 -0
- branchpy/engines/phase5_debug.txt +4 -0
- branchpy/engines/renpy_cfg.py +320 -0
- branchpy/engines/renpy_engine.py +2986 -0
- branchpy/engines/renpy_metadata_extractor.py +302 -0
- branchpy/engines/renpy_script_reads.py +215 -0
- branchpy/engines/renpy_ui_exposure_extractor.py +425 -0
- branchpy/engines/variable_detector.py +134 -0
- branchpy/errors.py +57 -0
- branchpy/explorers/__init__.py +28 -0
- branchpy/explorers/cache_manager.py +159 -0
- branchpy/explorers/label_fingerprints.py +264 -0
- branchpy/explorers/menu_nesting.py +429 -0
- branchpy/explorers/static_renpy_explorer.py +516 -0
- branchpy/export/destinations/__init__.py +179 -0
- branchpy/export/destinations/azure.py +192 -0
- branchpy/export/destinations/base.py +218 -0
- branchpy/export/destinations/gcs.py +173 -0
- branchpy/export/destinations/github.py +154 -0
- branchpy/export/destinations/local.py +242 -0
- branchpy/export/destinations/retention.py +156 -0
- branchpy/export/destinations/s3.py +194 -0
- branchpy/federation/__init__.py +61 -0
- branchpy/federation/config.py +176 -0
- branchpy/federation/federation.toml.example +102 -0
- branchpy/federation/importer.py +289 -0
- branchpy/federation/serializer.py +168 -0
- branchpy/federation/signed_links.py +276 -0
- branchpy/fp_logger.py +110 -0
- branchpy/git/__init__.py +1 -0
- branchpy/git/diff_tools.py +57 -0
- branchpy/git/hooks.py +44 -0
- branchpy/git/trailers.py +28 -0
- branchpy/governance/__init__.py +52 -0
- branchpy/governance/capabilities.py +39 -0
- branchpy/governance/hooks.py +82 -0
- branchpy/governance/template_apply.py +401 -0
- branchpy/governance/template_index.py +289 -0
- branchpy/governance/template_loader.py +338 -0
- branchpy/graph_builder.py +479 -0
- branchpy/history/__init__.py +24 -0
- branchpy/history/journal.py +112 -0
- branchpy/history/patch.py +206 -0
- branchpy/history/patch_helpers.py +292 -0
- branchpy/history/timeline.py +242 -0
- branchpy/hub/__init__.py +46 -0
- branchpy/hub/hub_client.py +762 -0
- branchpy/hub/local_state.py +413 -0
- branchpy/hub/models.py +378 -0
- branchpy/identity/__init__.py +35 -0
- branchpy/identity/local_provider.py +273 -0
- branchpy/identity/provider.py +135 -0
- branchpy/identity/session.py +226 -0
- branchpy/image_validation_v3/__init__.py +48 -0
- branchpy/image_validation_v3/cli.py +219 -0
- branchpy/image_validation_v3/cluster_engine.py +269 -0
- branchpy/image_validation_v3/cluster_v3.py +634 -0
- branchpy/image_validation_v3/feature_store.py +462 -0
- branchpy/image_validation_v3/media.defaults.json +95 -0
- branchpy/image_validation_v3/providers.py +86 -0
- branchpy/image_validation_v3/providers_v2/__init__.py +22 -0
- branchpy/image_validation_v3/providers_v2/adapters/__init__.py +1 -0
- branchpy/image_validation_v3/providers_v2/adapters/dropbox.py +291 -0
- branchpy/image_validation_v3/providers_v2/adapters/gdrive.py +303 -0
- branchpy/image_validation_v3/providers_v2/adapters/github.py +382 -0
- branchpy/image_validation_v3/providers_v2/adapters/mfiles.py +284 -0
- branchpy/image_validation_v3/providers_v2/adapters/onedrive.py +297 -0
- branchpy/image_validation_v3/providers_v2/adapters/webdav.py +321 -0
- branchpy/image_validation_v3/providers_v2/base.py +205 -0
- branchpy/image_validation_v3/providers_v2/credentials.py +269 -0
- branchpy/image_validation_v3/providers_v2/registry.py +187 -0
- branchpy/image_validation_v3/semantic_linker.py +327 -0
- branchpy/image_validation_v3/similarity.py +532 -0
- branchpy/image_validation_v3/validator.py +312 -0
- branchpy/insight_summary.py +485 -0
- branchpy/interactive_diff.py +160 -0
- branchpy/interactive_diff_adapter.py +226 -0
- branchpy/interfaces/runtime.py +19 -0
- branchpy/interfaces/semantic.py +25 -0
- branchpy/internals/__init__.py +3 -0
- branchpy/internals/graph_builder.py +485 -0
- branchpy/internals/story_validator.py +618 -0
- branchpy/l10n/__init__.py +17 -0
- branchpy/l10n/coverage.py +82 -0
- branchpy/l10n/extractor.py +186 -0
- branchpy/l10n/findings.py +119 -0
- branchpy/l10n/quality_rules.py +521 -0
- branchpy/license/__init__.py +69 -0
- branchpy/license/auth.py +569 -0
- branchpy/license/detection.py +192 -0
- branchpy/license/device.py +139 -0
- branchpy/license/entitlements.py +462 -0
- branchpy/license/exceptions.py +60 -0
- branchpy/license/gating.py +433 -0
- branchpy/license/keys.py +82 -0
- branchpy/license/snapshot.py +250 -0
- branchpy/license/status_core.py +271 -0
- branchpy/license.py +75 -0
- branchpy/license_manager.py +130 -0
- branchpy/localization/__init__.py +10 -0
- branchpy/localization/coverage_history.py +244 -0
- branchpy/localization/coverage_utils.py +290 -0
- branchpy/localization/trend_visualizer.py +770 -0
- branchpy/localization/validators.py +319 -0
- branchpy/localization/weighted_policy.py +500 -0
- branchpy/logging_setup.py +102 -0
- branchpy/logs.py +932 -0
- branchpy/media/dynamic_path_extractor.py +595 -0
- branchpy/media/media_events.py +136 -0
- branchpy/media/media_slo.py +174 -0
- branchpy/media/providers.py +579 -0
- branchpy/media/remote_context.py +138 -0
- branchpy/media/remote_paths.py +86 -0
- branchpy/media/scanner_cache.py +473 -0
- branchpy/media/scanner_integration.py +153 -0
- branchpy/media_analyzer.py +554 -0
- branchpy/media_renpy.py +977 -0
- branchpy/merge/__init__.py +26 -0
- branchpy/merge/merge_engine.py +508 -0
- branchpy/obs.py +181 -0
- branchpy/omega/__init__.py +121 -0
- branchpy/omega/derived_variables.py +376 -0
- branchpy/omega/domains.py +435 -0
- branchpy/omega/edit_cardinality.py +245 -0
- branchpy/omega/metrics_export.py +213 -0
- branchpy/omega/omega_report.py +301 -0
- branchpy/omega/pf_contextual.py +533 -0
- branchpy/omega/state_width.py +548 -0
- branchpy/omega/symbol_audit.py +292 -0
- branchpy/omega/visibility.py +293 -0
- branchpy/parser.py +162 -0
- branchpy/patch_state.py +40 -0
- branchpy/patch_store.py +87 -0
- branchpy/patches/__init__.py +120 -0
- branchpy/patches/autofix.py +587 -0
- branchpy/patches/engine.py +790 -0
- branchpy/patches/git_integration.py +432 -0
- branchpy/patches/models.py +469 -0
- branchpy/patches/storage.py +441 -0
- branchpy/paths.py +47 -0
- branchpy/performance/optimizations.py +278 -0
- branchpy/pilot/adapters.py +135 -0
- branchpy/pilot/collect_call_index.py +180 -0
- branchpy/pilot/sae_cfg_adapter.py +131 -0
- branchpy/plugins/git_safeguards/__init__.py +87 -0
- branchpy/plugins/git_safeguards/manifest.toml +94 -0
- branchpy/policy/__init__.py +14 -0
- branchpy/policy/eval.py +231 -0
- branchpy/policy/loader.py +40 -0
- branchpy/policy/rules.py +56 -0
- branchpy/policy/schema.toml +21 -0
- branchpy/policy/schemas/policy-v1.schema.json +110 -0
- branchpy/policy/schemas/team-v1.schema.json +97 -0
- branchpy/policy/templates/permissive.json +34 -0
- branchpy/policy/templates/strict-enforcement.json +76 -0
- branchpy/prerequisite_chain.py +250 -0
- branchpy/project.py +23 -0
- branchpy/project_config.py +476 -0
- branchpy/project_resolver.py +65 -0
- branchpy/providers/__init__.py +35 -0
- branchpy/providers/_telemetry.py +155 -0
- branchpy/providers/base.py +391 -0
- branchpy/providers/dropbox.py +659 -0
- branchpy/providers/mfiles.py +455 -0
- branchpy/providers/onedrive.py +814 -0
- branchpy/providers/webdav.py +649 -0
- branchpy/quickfix/add_type_hints.py +498 -0
- branchpy/quickfix/call_graph_viz.py +539 -0
- branchpy/quickfix/convert_fstring.py +287 -0
- branchpy/quickfix/extract_variable.py +341 -0
- branchpy/quickfix/inline_variable.py +303 -0
- branchpy/quickfix/split_long_line.py +279 -0
- branchpy/rbac/__init__.py +33 -0
- branchpy/rbac/config_loader.py +394 -0
- branchpy/rbac/permissions.py +167 -0
- branchpy/rbac/rbac_service.py +379 -0
- branchpy/reachability_analyzer.py +298 -0
- branchpy/remote/__init__.py +49 -0
- branchpy/remote/bootstrap/__init__.py +193 -0
- branchpy/remote/bootstrap/ci.py +165 -0
- branchpy/remote/bootstrap/codespaces.py +169 -0
- branchpy/remote/bootstrap/container.py +173 -0
- branchpy/remote/bootstrap/local_noop.py +59 -0
- branchpy/remote/bootstrap/models.py +79 -0
- branchpy/remote/bootstrap/ssh.py +161 -0
- branchpy/remote/bootstrap/strategies.py +17 -0
- branchpy/remote/bootstrap/wsl.py +138 -0
- branchpy/remote/bootstrap_doctor.py +799 -0
- branchpy/remote/cache.py +86 -0
- branchpy/remote/context.py +161 -0
- branchpy/remote/detector.py +416 -0
- branchpy/remote/path_mapper.py +99 -0
- branchpy/renderer/__init__.py +16 -0
- branchpy/renderer/base.py +83 -0
- branchpy/renderer/html.py +62 -0
- branchpy/renderer/json.py +30 -0
- branchpy/renderer/templates/analyze.html +370 -0
- branchpy/renderer/templates/base.html +37 -0
- branchpy/renderer/templates/compare.html +23 -0
- branchpy/renderer/templates/partials/l10n_coverage.html +66 -0
- branchpy/renderer/templates/stats.html +18 -0
- branchpy/renpy_sdk.py +447 -0
- branchpy/report.py +118 -0
- branchpy/report_writer.py +265 -0
- branchpy/rules/__init__.py +1 -0
- branchpy/rules/registry.py +47 -0
- branchpy/rules/v2/__init__.py +31 -0
- branchpy/rules/v2/api.py +265 -0
- branchpy/rules/v2/builtins/__init__.py +7 -0
- branchpy/rules/v2/builtins/header_comment_required.py +109 -0
- branchpy/rules/v2/builtins/image_namespace_style.py +115 -0
- branchpy/rules/v2/builtins/label_naming_style.py +151 -0
- branchpy/rules/v2/builtins/missing_image.py +194 -0
- branchpy/rules/v2/builtins/missing_image_definition.py +148 -0
- branchpy/rules/v2/builtins/naming_conventions.py +109 -0
- branchpy/rules/v2/builtins/patterns/__init__.py +27 -0
- branchpy/rules/v2/builtins/patterns/anti_patterns.py +741 -0
- branchpy/rules/v2/builtins/performance_limits.py +126 -0
- branchpy/rules/v2/builtins/test_coverage_missing.py +101 -0
- branchpy/rules/v2/context.py +252 -0
- branchpy/rules/v2/loader.py +294 -0
- branchpy/rules/v2/registry.py +95 -0
- branchpy/rules/v2/types.py +265 -0
- branchpy/run_context.py +81 -0
- branchpy/runners/__init__.py +28 -0
- branchpy/runners/checkpoint_manager.py +127 -0
- branchpy/runners/event_router.py +118 -0
- branchpy/runners/renpy_runner.py +750 -0
- branchpy/runners/trace_tailer.py +150 -0
- branchpy/sae/__init__.py +73 -0
- branchpy/sae/effects.py +42 -0
- branchpy/sae/guards.py +381 -0
- branchpy/sae/interpreter.py +210 -0
- branchpy/sae/lattice.py +62 -0
- branchpy/sae/merger.py +77 -0
- branchpy/sae/reconstruct.py +293 -0
- branchpy/sae/report.py +130 -0
- branchpy/sae/solver.py +408 -0
- branchpy/sae/state_tracker.py +608 -0
- branchpy/sae/unified_report_schema_v0_8_4.json +177 -0
- branchpy/save_point_analyzer.py +291 -0
- branchpy/scan_context.py +80 -0
- branchpy/sdk/__init__.py +111 -0
- branchpy/sdk/media.py +466 -0
- branchpy/semantics/__init__.py +1 -0
- branchpy/semantics/ast/__init__.py +57 -0
- branchpy/semantics/ast/ast_cache_manager.py +293 -0
- branchpy/semantics/ast/nodes.py +629 -0
- branchpy/semantics/ast/parser.py +1416 -0
- branchpy/semantics/ast/python_ast_parser.py +386 -0
- branchpy/semantics/bqf_wrapper_semantics.py +15 -0
- branchpy/semantics/cfg_builder.py +26 -0
- branchpy/semantics/conditional_rules.py +16 -0
- branchpy/semantics/cross_file_tracker.py +441 -0
- branchpy/semantics/effects_multi.py +25 -0
- branchpy/semantics/expressions/__init__.py +73 -0
- branchpy/semantics/expressions/errors.py +230 -0
- branchpy/semantics/expressions/nodes.py +307 -0
- branchpy/semantics/expressions/parser.py +487 -0
- branchpy/semantics/expressions/types.py +280 -0
- branchpy/semantics/expressions/validator.py +322 -0
- branchpy/semantics/expressions/variables/__init__.py +12 -0
- branchpy/semantics/expressions/variables/tracker.py +331 -0
- branchpy/semantics/propagation/__init__.py +56 -0
- branchpy/semantics/propagation/ai_cache.py +493 -0
- branchpy/semantics/propagation/ai_rule_engine.py +722 -0
- branchpy/semantics/propagation/bqf_policy_converter.py +710 -0
- branchpy/semantics/propagation/cfg_ai_engine.py +489 -0
- branchpy/semantics/propagation/cfg_builder.py +1141 -0
- branchpy/semantics/propagation/cfg_generator.py +682 -0
- branchpy/semantics/propagation/cfg_regex_engine.py +347 -0
- branchpy/semantics/propagation/cfg_rule_validator.py +288 -0
- branchpy/semantics/propagation/conditional_analyzer.py +667 -0
- branchpy/semantics/propagation/effects_analyzer.py +940 -0
- branchpy/semantics/propagation/effects_metrics.py +402 -0
- branchpy/semantics/propagation/flow_api.py +480 -0
- branchpy/semantics/propagation/metrics.py +376 -0
- branchpy/semantics/propagation/pfi_flow_integration.py +453 -0
- branchpy/semantics/propagation/propagator.py +508 -0
- branchpy/semantics/propagation/regex_rule_engine.py +524 -0
- branchpy/semantics/propagation/rule_registry.py +778 -0
- branchpy/semantics/propagation/rule_validator.py +734 -0
- branchpy/semantics/propagation/rule_versioning.py +498 -0
- branchpy/semantics/propagation/state.py +223 -0
- branchpy/semantics/regex_engine_v2.py +18 -0
- branchpy/semantics/schema.json +31 -0
- branchpy/semantics/semantic_history.py +29 -0
- branchpy/semantics_v2/__init__.py +65 -0
- branchpy/semantics_v2/ai_assisted_rules.py +119 -0
- branchpy/semantics_v2/conditional_analyzer.py +141 -0
- branchpy/semantics_v2/effects_analyzer.py +175 -0
- branchpy/semantics_v2/engine.py +731 -0
- branchpy/semantics_v2/parser.py +161 -0
- branchpy/semantics_v2/policy_exporter.py +164 -0
- branchpy/semantics_v2/regex_rules.py +139 -0
- branchpy/semantics_v2/semantic_graph_builder.py +653 -0
- branchpy/semantics_v2/semantic_history.py +170 -0
- branchpy/server/__init__.py +1 -0
- branchpy/server/api.py +505 -0
- branchpy/server/app.py +102 -0
- branchpy/server/auto_start.py +107 -0
- branchpy/server/daemon.py +474 -0
- branchpy/server/dto.py +343 -0
- branchpy/server/ensure.py +229 -0
- branchpy/server/events/INTEGRATION_GUIDE.py +88 -0
- branchpy/server/events/__init__.py +1 -0
- branchpy/server/events/bus.py +116 -0
- branchpy/server/events/helpers.py +197 -0
- branchpy/server/graph_filter.py +326 -0
- branchpy/server/pilot_paths.py +313 -0
- branchpy/server/port_manager.py +247 -0
- branchpy/server/project_resolver.py +301 -0
- branchpy/server/report_adapter.py +276 -0
- branchpy/server/routes/analyze.py +205 -0
- branchpy/server/routes/auth.py +116 -0
- branchpy/server/routes/auth_v2.py +622 -0
- branchpy/server/routes/charts.py +323 -0
- branchpy/server/routes/claim.py +233 -0
- branchpy/server/routes/compare.py +340 -0
- branchpy/server/routes/daemon.py +113 -0
- branchpy/server/routes/dashboard_logs.py +80 -0
- branchpy/server/routes/demo.py +51 -0
- branchpy/server/routes/device.py +310 -0
- branchpy/server/routes/editor.py +115 -0
- branchpy/server/routes/events.py +56 -0
- branchpy/server/routes/functions.py +215 -0
- branchpy/server/routes/issues.py +92 -0
- branchpy/server/routes/license.py +94 -0
- branchpy/server/routes/metrics.py +93 -0
- branchpy/server/routes/project.py +192 -0
- branchpy/server/routes/sae.py +486 -0
- branchpy/server/routes/semantics.py +1002 -0
- branchpy/server/routes/semantics_ufm.py +807 -0
- branchpy/server/routes/server.py +47 -0
- branchpy/server/routes/three_button.py +544 -0
- branchpy/server/routes/update.py +94 -0
- branchpy/server/routes/wow_data.py +541 -0
- branchpy/server/security.py +30 -0
- branchpy/server/serve.py +756 -0
- branchpy/server/static/assets/index-ByW6G6Nt.css +1 -0
- branchpy/server/static/assets/index-CvXUgfrM.js +85 -0
- branchpy/server/static/assets/index-Vf3eaeC8.js +85 -0
- branchpy/server/static/assets/index-umre-IgL.js +85 -0
- branchpy/server/static/index-KzpGriR7.js +70 -0
- branchpy/server/static/index.html +14 -0
- branchpy/server/static/vite.svg +1 -0
- branchpy/server/summarizer.py +405 -0
- branchpy/stats/__init__.py +79 -0
- branchpy/stats/metrics_source.py +471 -0
- branchpy/stats/policy_evaluator.py +569 -0
- branchpy/stats/policy_loader.py +361 -0
- branchpy/stats/policy_models.py +351 -0
- branchpy/stats/report_format.py +322 -0
- branchpy/stats2/__init__.py +39 -0
- branchpy/stats2/expressions.py +673 -0
- branchpy/story_graph.py +653 -0
- branchpy/story_validator.py +612 -0
- branchpy/support_bundle.py +248 -0
- branchpy/telemetry/__init__.py +94 -0
- branchpy/telemetry/analyzer_events.py +214 -0
- branchpy/telemetry/bqf_events.py +579 -0
- branchpy/telemetry/collector.py +243 -0
- branchpy/telemetry/collectors.py +540 -0
- branchpy/telemetry/config.py +129 -0
- branchpy/telemetry/emit_governance.py +69 -0
- branchpy/telemetry/event_emitter.py +47 -0
- branchpy/telemetry/events_compare.py +132 -0
- branchpy/telemetry/exporters/__init__.py +312 -0
- branchpy/telemetry/exporters/base.py +123 -0
- branchpy/telemetry/exporters/csv_exporter.py +53 -0
- branchpy/telemetry/exporters/json_exporter.py +42 -0
- branchpy/telemetry/exporters/parquet_exporter.py +76 -0
- branchpy/telemetry/exporters.py +262 -0
- branchpy/telemetry/governance_linker.py +322 -0
- branchpy/telemetry/ingest.py +149 -0
- branchpy/telemetry/integration_snippets.py +251 -0
- branchpy/telemetry/local_writer.py +214 -0
- branchpy/telemetry/mysql_sink.py +239 -0
- branchpy/telemetry/package_builder.py +499 -0
- branchpy/telemetry/package_schema.py +172 -0
- branchpy/telemetry/patch_events.py +273 -0
- branchpy/telemetry/paths.py +137 -0
- branchpy/telemetry/phase3_handler.py +443 -0
- branchpy/telemetry/privacy.py +297 -0
- branchpy/telemetry/prometheus.py +273 -0
- branchpy/telemetry/query.py +311 -0
- branchpy/telemetry/remote_events.py +379 -0
- branchpy/telemetry/retention.py +253 -0
- branchpy/telemetry/schema_validator.py +300 -0
- branchpy/telemetry/schemas.py +592 -0
- branchpy/telemetry/sdk_telemetry.py +647 -0
- branchpy/telemetry/storage.py +364 -0
- branchpy/telemetry/storage_composite.py +467 -0
- branchpy/telemetry/storage_mysql.py +608 -0
- branchpy/telemetry/storage_sqlite.py +596 -0
- branchpy/telemetry/ui_metrics.py +203 -0
- branchpy/telemetry/utils.py +165 -0
- branchpy/telemetry/validation_events.py +359 -0
- branchpy/telemetry/writer.py +226 -0
- branchpy/telemetry.py +80 -0
- branchpy/templates/renpy_autoplay_shim.rpy +274 -0
- branchpy/templates/renpy_trace_shim.rpy +130 -0
- branchpy/testing/__init__.py +10 -0
- branchpy/testing/coverage.py +67 -0
- branchpy/testing/coverage_finder.py +161 -0
- branchpy/testing/executor.py +560 -0
- branchpy/testing/planner.py +344 -0
- branchpy/tools/__init__.py +1 -0
- branchpy/tools/bugbundle.py +104 -0
- branchpy/tools/validate_cli.py +289 -0
- branchpy/update_manager.py +210 -0
- branchpy/utils/__init__.py +0 -0
- branchpy/utils/emit.py +34 -0
- branchpy/utils/env.py +35 -0
- branchpy/utils/git_engine.py +38 -0
- branchpy/utils/logs.py +108 -0
- branchpy/watcher.py +167 -0
- branchpy/ws/__init__.py +1 -0
- branchpy/ws/audit_tasks.py +323 -0
- branchpy/ws/daemon.py +347 -0
- branchpy/ws/daemon_http.py +237 -0
- branchpy/ws/handshake_routes.py +55 -0
- branchpy/ws/pilot_routes.py +283 -0
- branchpy/ws/run.py +1320 -0
- branchpy/ws/watcher.py +194 -0
- branchpy/ws/ws_hub.py +184 -0
- branchpy-dashboard/node_modules/flatted/python/flatted.py +149 -0
- branchpy_bootstrap/__init__.py +1 -0
- branchpy_bootstrap/bootstrap.py +140 -0
- branchpy_bootstrap/manifest.json +25 -0
- branchpy_cli-1.1.19.dist-info/METADATA +163 -0
- branchpy_cli-1.1.19.dist-info/RECORD +912 -0
- branchpy_cli-1.1.19.dist-info/WHEEL +5 -0
- branchpy_cli-1.1.19.dist-info/entry_points.txt +4 -0
- branchpy_cli-1.1.19.dist-info/licenses/LICENSE +38 -0
- branchpy_cli-1.1.19.dist-info/top_level.txt +6 -0
- graph_builder.py +487 -0
- story_validator.py +620 -0
bqf/__init__.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""
|
|
2
|
+
BQF (BranchPy Quality Framework) - Policy-based validation system.
|
|
3
|
+
|
|
4
|
+
This module provides the core infrastructure for BQF policy validation including:
|
|
5
|
+
- Policy registry (YAML-based configuration)
|
|
6
|
+
- Policy runner (dynamic validator loading and execution)
|
|
7
|
+
- Event emission (lifecycle tracking)
|
|
8
|
+
- Result aggregation (JSON formatting)
|
|
9
|
+
|
|
10
|
+
Version: 0.9.1.1
|
|
11
|
+
Created: 2025-11-12
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from .registry import PolicyRegistry, PolicyResult
|
|
15
|
+
|
|
16
|
+
__all__ = ["PolicyRegistry", "PolicyResult"]
|
bqf/registry.py
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"""
|
|
2
|
+
BQF Policy Registry - Dynamic policy loading and execution.
|
|
3
|
+
|
|
4
|
+
This module provides the PolicyRegistry class for:
|
|
5
|
+
- Loading policies from YAML configuration
|
|
6
|
+
- Dynamically importing validator modules
|
|
7
|
+
- Executing policies with event emission
|
|
8
|
+
- Aggregating results into JSON format
|
|
9
|
+
|
|
10
|
+
Version: 0.9.1.1
|
|
11
|
+
Created: 2025-11-12
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import time
|
|
15
|
+
from dataclasses import dataclass
|
|
16
|
+
from importlib import import_module
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
from typing import Literal, Optional
|
|
19
|
+
|
|
20
|
+
import yaml
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@dataclass
|
|
24
|
+
class PolicyResult:
|
|
25
|
+
"""Result from a single policy validator execution."""
|
|
26
|
+
|
|
27
|
+
policy_id: str
|
|
28
|
+
status: Literal["pass", "warn", "fail"]
|
|
29
|
+
messages: list[str]
|
|
30
|
+
duration_ms: float
|
|
31
|
+
metadata: dict
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class PolicyRegistry:
|
|
35
|
+
"""
|
|
36
|
+
BQF Policy Registry - manages policy loading and execution.
|
|
37
|
+
|
|
38
|
+
Usage:
|
|
39
|
+
registry = PolicyRegistry()
|
|
40
|
+
result = registry.run_policies("analyze", analysis_result, context)
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
def __init__(self, registry_path: Optional[Path] = None):
|
|
44
|
+
"""
|
|
45
|
+
Initialize policy registry.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
registry_path: Path to policies.yaml. If None, uses default location.
|
|
49
|
+
"""
|
|
50
|
+
if registry_path is None:
|
|
51
|
+
registry_path = Path(__file__).parent / "policies.yaml"
|
|
52
|
+
|
|
53
|
+
self.registry_path = registry_path
|
|
54
|
+
self.policies = self._load_policies()
|
|
55
|
+
|
|
56
|
+
def _load_policies(self) -> list[dict]:
|
|
57
|
+
"""Load policies from YAML configuration file."""
|
|
58
|
+
if not self.registry_path.exists():
|
|
59
|
+
raise FileNotFoundError(f"Policy registry not found: {self.registry_path}")
|
|
60
|
+
|
|
61
|
+
with open(self.registry_path, "r", encoding="utf-8") as f:
|
|
62
|
+
config = yaml.safe_load(f)
|
|
63
|
+
|
|
64
|
+
return config.get("policies", [])
|
|
65
|
+
|
|
66
|
+
def get_policies_for_module(
|
|
67
|
+
self, module: str, enabled_only: bool = True
|
|
68
|
+
) -> list[dict]:
|
|
69
|
+
"""
|
|
70
|
+
Get policies for a specific module.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
module: Module name ("analyze", "compare", "media")
|
|
74
|
+
enabled_only: If True, only return enabled policies
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
List of policy definitions for the module
|
|
78
|
+
"""
|
|
79
|
+
policies = [p for p in self.policies if p["module"] == module]
|
|
80
|
+
|
|
81
|
+
if enabled_only:
|
|
82
|
+
policies = [p for p in policies if p.get("enabled", True)]
|
|
83
|
+
|
|
84
|
+
return policies
|
|
85
|
+
|
|
86
|
+
def _import_validator(self, validator_path: str):
|
|
87
|
+
"""
|
|
88
|
+
Dynamically import validator function from module path.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
validator_path: Dotted path like "bqf.validators.analyze.story_structure.validate"
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
Validator function
|
|
95
|
+
"""
|
|
96
|
+
module_path, func_name = validator_path.rsplit(".", 1)
|
|
97
|
+
validator_module = import_module(module_path)
|
|
98
|
+
return getattr(validator_module, func_name)
|
|
99
|
+
|
|
100
|
+
def run_policies(self, module: str, analysis_result: dict, context: dict) -> dict:
|
|
101
|
+
"""
|
|
102
|
+
Run all enabled policies for a module.
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
module: Module name ("analyze", "compare", "media")
|
|
106
|
+
analysis_result: Full analysis/comparison/media result dict
|
|
107
|
+
context: Additional context (project_path, correlation_id, etc.)
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
Aggregated BQF result dict with format:
|
|
111
|
+
{
|
|
112
|
+
"policies_run": 2,
|
|
113
|
+
"policies_passed": 2,
|
|
114
|
+
"policies_warned": 0,
|
|
115
|
+
"policies_failed": 0,
|
|
116
|
+
"duration_ms": 1.23,
|
|
117
|
+
"details": [...] # Per-policy results
|
|
118
|
+
}
|
|
119
|
+
"""
|
|
120
|
+
policies = self.get_policies_for_module(module, enabled_only=True)
|
|
121
|
+
|
|
122
|
+
if not policies:
|
|
123
|
+
return {
|
|
124
|
+
"policies_run": 0,
|
|
125
|
+
"policies_passed": 0,
|
|
126
|
+
"policies_warned": 0,
|
|
127
|
+
"policies_failed": 0,
|
|
128
|
+
"duration_ms": 0.0,
|
|
129
|
+
"details": [],
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
# Emit start event (TODO: integrate with governance.events)
|
|
133
|
+
correlation_id = context.get("correlation_id", "unknown")
|
|
134
|
+
self._emit_event(
|
|
135
|
+
"validation.policy.start",
|
|
136
|
+
{
|
|
137
|
+
"module": module,
|
|
138
|
+
"policy_count": len(policies),
|
|
139
|
+
"correlationId": correlation_id,
|
|
140
|
+
},
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
start_time = time.perf_counter()
|
|
144
|
+
results = []
|
|
145
|
+
|
|
146
|
+
for policy in policies:
|
|
147
|
+
try:
|
|
148
|
+
# Dynamically load validator
|
|
149
|
+
validator_func = self._import_validator(policy["validator"])
|
|
150
|
+
|
|
151
|
+
# Run validation
|
|
152
|
+
result = validator_func(analysis_result, context)
|
|
153
|
+
results.append(result)
|
|
154
|
+
|
|
155
|
+
except Exception as e:
|
|
156
|
+
# If validator fails to load or execute, treat as failure
|
|
157
|
+
results.append(
|
|
158
|
+
PolicyResult(
|
|
159
|
+
policy_id=policy["id"],
|
|
160
|
+
status="fail",
|
|
161
|
+
messages=[f"Validator error: {str(e)}"],
|
|
162
|
+
duration_ms=0.0,
|
|
163
|
+
metadata={"error": str(e)},
|
|
164
|
+
)
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
total_duration_ms = (time.perf_counter() - start_time) * 1000
|
|
168
|
+
|
|
169
|
+
# Aggregate results (treat "info" as "warn" for counting)
|
|
170
|
+
aggregated = {
|
|
171
|
+
"policies_run": len(results),
|
|
172
|
+
"policies_passed": sum(1 for r in results if r.status == "pass"),
|
|
173
|
+
"policies_warned": sum(1 for r in results if r.status in ("warn", "info")),
|
|
174
|
+
"policies_failed": sum(1 for r in results if r.status == "fail"),
|
|
175
|
+
"duration_ms": round(total_duration_ms, 4),
|
|
176
|
+
"details": [
|
|
177
|
+
{
|
|
178
|
+
"policy_id": r.policy_id,
|
|
179
|
+
"status": r.status,
|
|
180
|
+
"messages": r.messages,
|
|
181
|
+
"duration_ms": round(r.duration_ms, 4),
|
|
182
|
+
"metadata": r.metadata,
|
|
183
|
+
}
|
|
184
|
+
for r in results
|
|
185
|
+
],
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
# Emit complete event
|
|
189
|
+
self._emit_event(
|
|
190
|
+
"validation.policy.complete",
|
|
191
|
+
{"module": module, "results": aggregated, "correlationId": correlation_id},
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
return aggregated
|
|
195
|
+
|
|
196
|
+
def _emit_event(self, event_name: str, data: dict):
|
|
197
|
+
"""
|
|
198
|
+
Emit governance event (placeholder for future integration).
|
|
199
|
+
|
|
200
|
+
Args:
|
|
201
|
+
event_name: Event name following domain.action.phase pattern
|
|
202
|
+
data: Event data payload
|
|
203
|
+
|
|
204
|
+
TODO: Integrate with governance.events module in v0.9.2
|
|
205
|
+
"""
|
|
206
|
+
# For now, just log to console (will integrate with governance logger later)
|
|
207
|
+
# print(f"[BQF EVENT] {event_name}: {data}")
|
|
208
|
+
pass # Silent for now, will wire to governance.events in v0.9.2
|
branchpy/__init__.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from . import cli # exposes branchpy.cli
|
|
2
|
+
from . import parser, report
|
|
3
|
+
from .contract import VERSION
|
|
4
|
+
|
|
5
|
+
# Try to import telemetry and governance, but don't fail if they have optional dependencies
|
|
6
|
+
try:
|
|
7
|
+
from . import telemetry
|
|
8
|
+
except (ImportError, ModuleNotFoundError):
|
|
9
|
+
# telemetry has optional dependencies, skip if not available
|
|
10
|
+
pass
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
from . import governance
|
|
14
|
+
except (ImportError, ModuleNotFoundError):
|
|
15
|
+
# governance may have optional dependencies, skip if not available
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
# Expose version as both VERSION and __version__ for compatibility
|
|
19
|
+
__version__ = VERSION
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"cli",
|
|
23
|
+
"parser",
|
|
24
|
+
"report",
|
|
25
|
+
"telemetry",
|
|
26
|
+
"governance",
|
|
27
|
+
"VERSION",
|
|
28
|
+
"__version__",
|
|
29
|
+
]
|
branchpy/__main__.py
ADDED
branchpy/ai/__init__.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""
|
|
2
|
+
branchpy.ai.__init__.py
|
|
3
|
+
BranchPy v1.0.0 — AI Integration Strategy
|
|
4
|
+
|
|
5
|
+
AI-as-a-Service module for BranchPy.
|
|
6
|
+
Supports multiple providers (OpenAI, Anthropic, Ollama, Venice.ai) with local API keys.
|
|
7
|
+
|
|
8
|
+
Governance:
|
|
9
|
+
- All AI operations emit governance events
|
|
10
|
+
- Privacy-preserving: no data sent to BranchPy servers
|
|
11
|
+
- User-controlled API keys
|
|
12
|
+
|
|
13
|
+
Local AI Support:
|
|
14
|
+
- Ollama provider for local Llama models (100% private)
|
|
15
|
+
- LM Studio support (OpenAI-compatible)
|
|
16
|
+
- Safe mode restricts to local-only providers
|
|
17
|
+
|
|
18
|
+
BQS Compliance:
|
|
19
|
+
- Input validation on all API calls
|
|
20
|
+
- Rate limiting and error handling
|
|
21
|
+
- Cross-platform compatibility
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from .ai_models import AIModel, AITask
|
|
25
|
+
from .ai_routing import AIRouter
|
|
26
|
+
from .config import AIConfig, ProviderConfig, load_ai_config
|
|
27
|
+
from .protocol import AIProvider, ChatRequest, ChatResponse, Message, TokenUsage
|
|
28
|
+
from .provider_manager import ProviderManager
|
|
29
|
+
from .providers.ollama_provider import OllamaProvider
|
|
30
|
+
from .providers.venice_provider import VeniceProvider
|
|
31
|
+
|
|
32
|
+
__all__ = [
|
|
33
|
+
"ProviderManager",
|
|
34
|
+
"AIModel",
|
|
35
|
+
"AITask",
|
|
36
|
+
"AIRouter",
|
|
37
|
+
"AIProvider",
|
|
38
|
+
"ChatRequest",
|
|
39
|
+
"ChatResponse",
|
|
40
|
+
"Message",
|
|
41
|
+
"TokenUsage",
|
|
42
|
+
"ProviderConfig",
|
|
43
|
+
"AIConfig",
|
|
44
|
+
"load_ai_config",
|
|
45
|
+
"OllamaProvider",
|
|
46
|
+
"VeniceProvider",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
__version__ = "1.0.0"
|
branchpy/ai/ai_models.py
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""
|
|
2
|
+
branchpy.ai.ai_models.py
|
|
3
|
+
BranchPy v0.9.4 — AI Integration Strategy
|
|
4
|
+
|
|
5
|
+
AI models and task definitions
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from dataclasses import dataclass
|
|
9
|
+
from enum import Enum
|
|
10
|
+
from typing import Any, Dict, Optional
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class AIModel(Enum):
|
|
14
|
+
"""Supported AI models"""
|
|
15
|
+
|
|
16
|
+
GPT4 = "gpt-4"
|
|
17
|
+
GPT4_TURBO = "gpt-4-turbo"
|
|
18
|
+
GPT5 = "gpt-5" # Future
|
|
19
|
+
CLAUDE_35_SONNET = "claude-3-5-sonnet-20241022"
|
|
20
|
+
CLAUDE_45 = "claude-4-5" # Future
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class AITask(Enum):
|
|
24
|
+
"""AI task types"""
|
|
25
|
+
|
|
26
|
+
CODE_REVIEW = "code_review"
|
|
27
|
+
DOCGEN = "documentation_generation"
|
|
28
|
+
SEMANTIC_ASSIST = "semantic_assistance"
|
|
29
|
+
ASSET_GUESS = "asset_guessing"
|
|
30
|
+
EXPLAIN_WARNING = "explain_warning"
|
|
31
|
+
HELP = "help_support"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@dataclass
|
|
35
|
+
class AIRequest:
|
|
36
|
+
"""AI request data structure"""
|
|
37
|
+
|
|
38
|
+
task: AITask
|
|
39
|
+
provider: str
|
|
40
|
+
model: str
|
|
41
|
+
input_data: Dict[str, Any]
|
|
42
|
+
context: Optional[Dict[str, Any]] = None
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@dataclass
|
|
46
|
+
class AIResponse:
|
|
47
|
+
"""AI response data structure"""
|
|
48
|
+
|
|
49
|
+
task: AITask
|
|
50
|
+
provider: str
|
|
51
|
+
model: str
|
|
52
|
+
output: Any
|
|
53
|
+
metadata: Optional[Dict[str, Any]] = None
|
|
54
|
+
error: Optional[str] = None
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@dataclass
|
|
58
|
+
class AIConfig:
|
|
59
|
+
"""AI configuration"""
|
|
60
|
+
|
|
61
|
+
provider: str
|
|
62
|
+
api_key: str
|
|
63
|
+
model: Optional[str] = None
|
|
64
|
+
temperature: float = 0.5
|
|
65
|
+
max_tokens: int = 4096
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"""
|
|
2
|
+
branchpy.ai.ai_routing.py
|
|
3
|
+
BranchPy v0.9.4 — AI Integration Strategy
|
|
4
|
+
|
|
5
|
+
AI task routing and execution
|
|
6
|
+
Routes tasks to appropriate providers based on configuration and task type
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from typing import Any, Dict, Optional
|
|
10
|
+
|
|
11
|
+
from .ai_models import AIRequest, AIResponse, AITask
|
|
12
|
+
from .provider_manager import AIProvider, ProviderManager
|
|
13
|
+
from .providers.anthropic_provider import AnthropicProvider
|
|
14
|
+
from .providers.openai_provider import OpenAIProvider
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class AIRouter:
|
|
18
|
+
"""
|
|
19
|
+
Routes AI tasks to appropriate providers.
|
|
20
|
+
|
|
21
|
+
Handles:
|
|
22
|
+
- Provider selection
|
|
23
|
+
- Task routing
|
|
24
|
+
- Error handling
|
|
25
|
+
- Governance event emission
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(self):
|
|
29
|
+
self.provider_manager = ProviderManager()
|
|
30
|
+
self._providers: Dict[str, Any] = {}
|
|
31
|
+
|
|
32
|
+
def _get_provider_instance(self, provider: AIProvider):
|
|
33
|
+
"""Get or create provider instance"""
|
|
34
|
+
if provider.value in self._providers:
|
|
35
|
+
return self._providers[provider.value]
|
|
36
|
+
|
|
37
|
+
api_key = self.provider_manager.get_api_key(provider)
|
|
38
|
+
if not api_key:
|
|
39
|
+
raise ValueError(f"No API key configured for {provider.value}")
|
|
40
|
+
|
|
41
|
+
model = self.provider_manager.get_model(provider)
|
|
42
|
+
|
|
43
|
+
if provider == AIProvider.OPENAI:
|
|
44
|
+
instance = OpenAIProvider(api_key, model or "gpt-4")
|
|
45
|
+
elif provider == AIProvider.ANTHROPIC:
|
|
46
|
+
instance = AnthropicProvider(api_key, model or "claude-3-5-sonnet-20241022")
|
|
47
|
+
else:
|
|
48
|
+
raise ValueError(f"Unsupported provider: {provider}")
|
|
49
|
+
|
|
50
|
+
self._providers[provider.value] = instance
|
|
51
|
+
return instance
|
|
52
|
+
|
|
53
|
+
def execute(self, request: AIRequest) -> AIResponse:
|
|
54
|
+
"""
|
|
55
|
+
Execute an AI task.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
request: AI request
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
AI response
|
|
62
|
+
"""
|
|
63
|
+
try:
|
|
64
|
+
# Get provider
|
|
65
|
+
provider = AIProvider(request.provider)
|
|
66
|
+
instance = self._get_provider_instance(provider)
|
|
67
|
+
|
|
68
|
+
# Route task
|
|
69
|
+
if request.task == AITask.CODE_REVIEW:
|
|
70
|
+
output = instance.code_review(
|
|
71
|
+
code=request.input_data["code"],
|
|
72
|
+
language=request.input_data.get("language", "python"),
|
|
73
|
+
)
|
|
74
|
+
elif request.task == AITask.DOCGEN:
|
|
75
|
+
output = instance.generate_documentation(
|
|
76
|
+
code=request.input_data["code"],
|
|
77
|
+
doc_type=request.input_data.get("doc_type", "readme"),
|
|
78
|
+
)
|
|
79
|
+
elif request.task == AITask.EXPLAIN_WARNING:
|
|
80
|
+
output = instance.explain_warning(
|
|
81
|
+
warning_text=request.input_data["warning"],
|
|
82
|
+
context=request.input_data.get("context"),
|
|
83
|
+
)
|
|
84
|
+
elif request.task == AITask.ASSET_GUESS:
|
|
85
|
+
if provider == AIProvider.ANTHROPIC:
|
|
86
|
+
output = instance.guess_asset(
|
|
87
|
+
asset_context=request.input_data["context"],
|
|
88
|
+
available_assets=request.input_data["available_assets"],
|
|
89
|
+
)
|
|
90
|
+
else:
|
|
91
|
+
output = {"error": "Asset guessing only supported on Anthropic"}
|
|
92
|
+
else:
|
|
93
|
+
output = {"error": f"Unsupported task: {request.task}"}
|
|
94
|
+
|
|
95
|
+
return AIResponse(
|
|
96
|
+
task=request.task,
|
|
97
|
+
provider=request.provider,
|
|
98
|
+
model=request.model,
|
|
99
|
+
output=output,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
except Exception as e:
|
|
103
|
+
return AIResponse(
|
|
104
|
+
task=request.task,
|
|
105
|
+
provider=request.provider,
|
|
106
|
+
model=request.model,
|
|
107
|
+
output=None,
|
|
108
|
+
error=str(e),
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
def is_available(self, provider: Optional[AIProvider] = None) -> bool:
|
|
112
|
+
"""Check if AI is available"""
|
|
113
|
+
if provider is None:
|
|
114
|
+
provider = self.provider_manager.get_active_provider()
|
|
115
|
+
|
|
116
|
+
if provider is None:
|
|
117
|
+
return False
|
|
118
|
+
|
|
119
|
+
return self.provider_manager.is_configured(provider)
|
branchpy/ai/ai_tasks.py
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"""
|
|
2
|
+
branchpy.ai.ai_tasks.py
|
|
3
|
+
BranchPy v0.9.4 — AI Integration Strategy
|
|
4
|
+
|
|
5
|
+
High-level AI task implementations
|
|
6
|
+
Convenience functions for common AI operations
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from typing import Any, Dict, List, Optional
|
|
10
|
+
|
|
11
|
+
from .ai_models import AIRequest, AITask
|
|
12
|
+
from .ai_routing import AIRouter
|
|
13
|
+
from .provider_manager import ProviderManager
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def code_review(
|
|
17
|
+
file_path: str, code: Optional[str] = None, language: str = "python"
|
|
18
|
+
) -> Dict[str, Any]:
|
|
19
|
+
"""
|
|
20
|
+
Run AI code review on a file.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
file_path: Path to file
|
|
24
|
+
code: Optional code string (if not provided, read from file)
|
|
25
|
+
language: Programming language
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
Review results
|
|
29
|
+
"""
|
|
30
|
+
try:
|
|
31
|
+
if code is None:
|
|
32
|
+
with open(file_path, "r", encoding="utf-8") as f:
|
|
33
|
+
code = f.read()
|
|
34
|
+
except FileNotFoundError:
|
|
35
|
+
return {"error": f"File not found: {file_path}", "findings": []}
|
|
36
|
+
except Exception as e:
|
|
37
|
+
return {"error": f"Failed to read file: {str(e)}", "findings": []}
|
|
38
|
+
|
|
39
|
+
pm = ProviderManager()
|
|
40
|
+
provider = pm.get_active_provider()
|
|
41
|
+
|
|
42
|
+
if provider is None:
|
|
43
|
+
return {"error": "No AI provider configured", "findings": []}
|
|
44
|
+
|
|
45
|
+
model = pm.get_model(provider) or "default"
|
|
46
|
+
|
|
47
|
+
request = AIRequest(
|
|
48
|
+
task=AITask.CODE_REVIEW,
|
|
49
|
+
provider=provider.value,
|
|
50
|
+
model=model,
|
|
51
|
+
input_data={"code": code, "language": language},
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
router = AIRouter()
|
|
55
|
+
response = router.execute(request)
|
|
56
|
+
|
|
57
|
+
if response.error:
|
|
58
|
+
return {"error": response.error, "findings": []}
|
|
59
|
+
|
|
60
|
+
return response.output
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def generate_docs(code: str, doc_type: str = "readme") -> str:
|
|
64
|
+
"""
|
|
65
|
+
Generate documentation for code.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
code: Source code
|
|
69
|
+
doc_type: Documentation type
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
Generated documentation
|
|
73
|
+
"""
|
|
74
|
+
pm = ProviderManager()
|
|
75
|
+
provider = pm.get_active_provider()
|
|
76
|
+
|
|
77
|
+
if provider is None:
|
|
78
|
+
return "Error: No AI provider configured"
|
|
79
|
+
|
|
80
|
+
model = pm.get_model(provider) or "default"
|
|
81
|
+
|
|
82
|
+
request = AIRequest(
|
|
83
|
+
task=AITask.DOCGEN,
|
|
84
|
+
provider=provider.value,
|
|
85
|
+
model=model,
|
|
86
|
+
input_data={"code": code, "doc_type": doc_type},
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
router = AIRouter()
|
|
90
|
+
response = router.execute(request)
|
|
91
|
+
|
|
92
|
+
if response.error:
|
|
93
|
+
return f"Error: {response.error}"
|
|
94
|
+
|
|
95
|
+
return response.output
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def explain_warning(warning_text: str, context: Optional[str] = None) -> str:
|
|
99
|
+
"""
|
|
100
|
+
Get AI explanation for a warning.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
warning_text: Warning message
|
|
104
|
+
context: Optional context
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
Explanation
|
|
108
|
+
"""
|
|
109
|
+
pm = ProviderManager()
|
|
110
|
+
provider = pm.get_active_provider()
|
|
111
|
+
|
|
112
|
+
if provider is None:
|
|
113
|
+
return "Error: No AI provider configured"
|
|
114
|
+
|
|
115
|
+
model = pm.get_model(provider) or "default"
|
|
116
|
+
|
|
117
|
+
request = AIRequest(
|
|
118
|
+
task=AITask.EXPLAIN_WARNING,
|
|
119
|
+
provider=provider.value,
|
|
120
|
+
model=model,
|
|
121
|
+
input_data={"warning": warning_text, "context": context},
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
router = AIRouter()
|
|
125
|
+
response = router.execute(request)
|
|
126
|
+
|
|
127
|
+
if response.error:
|
|
128
|
+
return f"Error: {response.error}"
|
|
129
|
+
|
|
130
|
+
return response.output
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def guess_missing_asset(context: str, available_assets: List[str]) -> List[str]:
|
|
134
|
+
"""
|
|
135
|
+
Guess missing asset based on context.
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
context: Asset context
|
|
139
|
+
available_assets: Available asset filenames
|
|
140
|
+
|
|
141
|
+
Returns:
|
|
142
|
+
List of suggestions
|
|
143
|
+
"""
|
|
144
|
+
pm = ProviderManager()
|
|
145
|
+
provider = pm.get_active_provider()
|
|
146
|
+
|
|
147
|
+
if provider is None:
|
|
148
|
+
return []
|
|
149
|
+
|
|
150
|
+
model = pm.get_model(provider) or "default"
|
|
151
|
+
|
|
152
|
+
request = AIRequest(
|
|
153
|
+
task=AITask.ASSET_GUESS,
|
|
154
|
+
provider=provider.value,
|
|
155
|
+
model=model,
|
|
156
|
+
input_data={"context": context, "available_assets": available_assets},
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
router = AIRouter()
|
|
160
|
+
response = router.execute(request)
|
|
161
|
+
|
|
162
|
+
if response.error:
|
|
163
|
+
return []
|
|
164
|
+
|
|
165
|
+
return response.output if isinstance(response.output, list) else []
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""AI integration with Python AST analysis.
|
|
2
|
+
|
|
3
|
+
This module provides AI-powered code analysis using rich context
|
|
4
|
+
extracted from Python AST nodes.
|
|
5
|
+
|
|
6
|
+
Components:
|
|
7
|
+
- ast_context: Extract rich context from AST for AI operations
|
|
8
|
+
- code_review: AI-powered code review
|
|
9
|
+
- explain_warning: AI explanations of BranchPy warnings
|
|
10
|
+
- refactor: AI-powered refactoring suggestions
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from .ast_context import AIContext, ASTContextBuilder
|
|
14
|
+
from .code_review import AICodeReviewer, CodeReview
|
|
15
|
+
from .explain_warning import AIWarningExplainer, WarningExplanation
|
|
16
|
+
from .refactor import AIRefactorSuggester, RefactoringPatch, RefactorSuggestion
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"ASTContextBuilder",
|
|
20
|
+
"AIContext",
|
|
21
|
+
"AICodeReviewer",
|
|
22
|
+
"CodeReview",
|
|
23
|
+
"AIWarningExplainer",
|
|
24
|
+
"WarningExplanation",
|
|
25
|
+
"AIRefactorSuggester",
|
|
26
|
+
"RefactorSuggestion",
|
|
27
|
+
"RefactoringPatch",
|
|
28
|
+
]
|