crackerjack 0.18.2__py3-none-any.whl → 0.45.2__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.
- crackerjack/README.md +19 -0
- crackerjack/__init__.py +96 -2
- crackerjack/__main__.py +637 -138
- crackerjack/adapters/README.md +18 -0
- crackerjack/adapters/__init__.py +39 -0
- crackerjack/adapters/_output_paths.py +167 -0
- crackerjack/adapters/_qa_adapter_base.py +309 -0
- crackerjack/adapters/_tool_adapter_base.py +706 -0
- crackerjack/adapters/ai/README.md +65 -0
- crackerjack/adapters/ai/__init__.py +5 -0
- crackerjack/adapters/ai/claude.py +853 -0
- crackerjack/adapters/complexity/README.md +53 -0
- crackerjack/adapters/complexity/__init__.py +10 -0
- crackerjack/adapters/complexity/complexipy.py +641 -0
- crackerjack/adapters/dependency/__init__.py +22 -0
- crackerjack/adapters/dependency/pip_audit.py +418 -0
- crackerjack/adapters/format/README.md +72 -0
- crackerjack/adapters/format/__init__.py +11 -0
- crackerjack/adapters/format/mdformat.py +313 -0
- crackerjack/adapters/format/ruff.py +516 -0
- crackerjack/adapters/lint/README.md +47 -0
- crackerjack/adapters/lint/__init__.py +11 -0
- crackerjack/adapters/lint/codespell.py +273 -0
- crackerjack/adapters/lsp/README.md +49 -0
- crackerjack/adapters/lsp/__init__.py +27 -0
- crackerjack/adapters/lsp/_base.py +194 -0
- crackerjack/adapters/lsp/_client.py +358 -0
- crackerjack/adapters/lsp/_manager.py +193 -0
- crackerjack/adapters/lsp/skylos.py +283 -0
- crackerjack/adapters/lsp/zuban.py +557 -0
- crackerjack/adapters/refactor/README.md +59 -0
- crackerjack/adapters/refactor/__init__.py +12 -0
- crackerjack/adapters/refactor/creosote.py +318 -0
- crackerjack/adapters/refactor/refurb.py +406 -0
- crackerjack/adapters/refactor/skylos.py +494 -0
- crackerjack/adapters/sast/README.md +132 -0
- crackerjack/adapters/sast/__init__.py +32 -0
- crackerjack/adapters/sast/_base.py +201 -0
- crackerjack/adapters/sast/bandit.py +423 -0
- crackerjack/adapters/sast/pyscn.py +405 -0
- crackerjack/adapters/sast/semgrep.py +241 -0
- crackerjack/adapters/security/README.md +111 -0
- crackerjack/adapters/security/__init__.py +17 -0
- crackerjack/adapters/security/gitleaks.py +339 -0
- crackerjack/adapters/type/README.md +52 -0
- crackerjack/adapters/type/__init__.py +12 -0
- crackerjack/adapters/type/pyrefly.py +402 -0
- crackerjack/adapters/type/ty.py +402 -0
- crackerjack/adapters/type/zuban.py +522 -0
- crackerjack/adapters/utility/README.md +51 -0
- crackerjack/adapters/utility/__init__.py +10 -0
- crackerjack/adapters/utility/checks.py +884 -0
- crackerjack/agents/README.md +264 -0
- crackerjack/agents/__init__.py +66 -0
- crackerjack/agents/architect_agent.py +238 -0
- crackerjack/agents/base.py +167 -0
- crackerjack/agents/claude_code_bridge.py +641 -0
- crackerjack/agents/coordinator.py +600 -0
- crackerjack/agents/documentation_agent.py +520 -0
- crackerjack/agents/dry_agent.py +585 -0
- crackerjack/agents/enhanced_coordinator.py +279 -0
- crackerjack/agents/enhanced_proactive_agent.py +185 -0
- crackerjack/agents/error_middleware.py +53 -0
- crackerjack/agents/formatting_agent.py +230 -0
- crackerjack/agents/helpers/__init__.py +9 -0
- crackerjack/agents/helpers/performance/__init__.py +22 -0
- crackerjack/agents/helpers/performance/performance_ast_analyzer.py +357 -0
- crackerjack/agents/helpers/performance/performance_pattern_detector.py +909 -0
- crackerjack/agents/helpers/performance/performance_recommender.py +572 -0
- crackerjack/agents/helpers/refactoring/__init__.py +22 -0
- crackerjack/agents/helpers/refactoring/code_transformer.py +536 -0
- crackerjack/agents/helpers/refactoring/complexity_analyzer.py +344 -0
- crackerjack/agents/helpers/refactoring/dead_code_detector.py +437 -0
- crackerjack/agents/helpers/test_creation/__init__.py +19 -0
- crackerjack/agents/helpers/test_creation/test_ast_analyzer.py +216 -0
- crackerjack/agents/helpers/test_creation/test_coverage_analyzer.py +643 -0
- crackerjack/agents/helpers/test_creation/test_template_generator.py +1031 -0
- crackerjack/agents/import_optimization_agent.py +1181 -0
- crackerjack/agents/performance_agent.py +325 -0
- crackerjack/agents/performance_helpers.py +205 -0
- crackerjack/agents/proactive_agent.py +55 -0
- crackerjack/agents/refactoring_agent.py +511 -0
- crackerjack/agents/refactoring_helpers.py +247 -0
- crackerjack/agents/security_agent.py +793 -0
- crackerjack/agents/semantic_agent.py +479 -0
- crackerjack/agents/semantic_helpers.py +356 -0
- crackerjack/agents/test_creation_agent.py +570 -0
- crackerjack/agents/test_specialist_agent.py +526 -0
- crackerjack/agents/tracker.py +110 -0
- crackerjack/api.py +647 -0
- crackerjack/cli/README.md +394 -0
- crackerjack/cli/__init__.py +24 -0
- crackerjack/cli/cache_handlers.py +209 -0
- crackerjack/cli/cache_handlers_enhanced.py +680 -0
- crackerjack/cli/facade.py +162 -0
- crackerjack/cli/formatting.py +13 -0
- crackerjack/cli/handlers/__init__.py +85 -0
- crackerjack/cli/handlers/advanced.py +103 -0
- crackerjack/cli/handlers/ai_features.py +62 -0
- crackerjack/cli/handlers/analytics.py +479 -0
- crackerjack/cli/handlers/changelog.py +271 -0
- crackerjack/cli/handlers/config_handlers.py +16 -0
- crackerjack/cli/handlers/coverage.py +84 -0
- crackerjack/cli/handlers/documentation.py +280 -0
- crackerjack/cli/handlers/main_handlers.py +497 -0
- crackerjack/cli/handlers/monitoring.py +371 -0
- crackerjack/cli/handlers.py +700 -0
- crackerjack/cli/interactive.py +488 -0
- crackerjack/cli/options.py +1216 -0
- crackerjack/cli/semantic_handlers.py +292 -0
- crackerjack/cli/utils.py +19 -0
- crackerjack/cli/version.py +19 -0
- crackerjack/code_cleaner.py +1307 -0
- crackerjack/config/README.md +472 -0
- crackerjack/config/__init__.py +275 -0
- crackerjack/config/global_lock_config.py +207 -0
- crackerjack/config/hooks.py +390 -0
- crackerjack/config/loader.py +239 -0
- crackerjack/config/settings.py +141 -0
- crackerjack/config/tool_commands.py +331 -0
- crackerjack/core/README.md +393 -0
- crackerjack/core/__init__.py +0 -0
- crackerjack/core/async_workflow_orchestrator.py +738 -0
- crackerjack/core/autofix_coordinator.py +282 -0
- crackerjack/core/container.py +105 -0
- crackerjack/core/enhanced_container.py +583 -0
- crackerjack/core/file_lifecycle.py +472 -0
- crackerjack/core/performance.py +244 -0
- crackerjack/core/performance_monitor.py +357 -0
- crackerjack/core/phase_coordinator.py +1227 -0
- crackerjack/core/proactive_workflow.py +267 -0
- crackerjack/core/resource_manager.py +425 -0
- crackerjack/core/retry.py +275 -0
- crackerjack/core/service_watchdog.py +601 -0
- crackerjack/core/session_coordinator.py +239 -0
- crackerjack/core/timeout_manager.py +563 -0
- crackerjack/core/websocket_lifecycle.py +410 -0
- crackerjack/core/workflow/__init__.py +21 -0
- crackerjack/core/workflow/workflow_ai_coordinator.py +863 -0
- crackerjack/core/workflow/workflow_event_orchestrator.py +1107 -0
- crackerjack/core/workflow/workflow_issue_parser.py +714 -0
- crackerjack/core/workflow/workflow_phase_executor.py +1158 -0
- crackerjack/core/workflow/workflow_security_gates.py +400 -0
- crackerjack/core/workflow_orchestrator.py +2243 -0
- crackerjack/data/README.md +11 -0
- crackerjack/data/__init__.py +8 -0
- crackerjack/data/models.py +79 -0
- crackerjack/data/repository.py +210 -0
- crackerjack/decorators/README.md +180 -0
- crackerjack/decorators/__init__.py +35 -0
- crackerjack/decorators/error_handling.py +649 -0
- crackerjack/decorators/error_handling_decorators.py +334 -0
- crackerjack/decorators/helpers.py +58 -0
- crackerjack/decorators/patterns.py +281 -0
- crackerjack/decorators/utils.py +58 -0
- crackerjack/docs/INDEX.md +11 -0
- crackerjack/docs/README.md +11 -0
- crackerjack/docs/generated/api/API_REFERENCE.md +10895 -0
- crackerjack/docs/generated/api/CLI_REFERENCE.md +109 -0
- crackerjack/docs/generated/api/CROSS_REFERENCES.md +1755 -0
- crackerjack/docs/generated/api/PROTOCOLS.md +3 -0
- crackerjack/docs/generated/api/SERVICES.md +1252 -0
- crackerjack/documentation/README.md +11 -0
- crackerjack/documentation/__init__.py +31 -0
- crackerjack/documentation/ai_templates.py +756 -0
- crackerjack/documentation/dual_output_generator.py +767 -0
- crackerjack/documentation/mkdocs_integration.py +518 -0
- crackerjack/documentation/reference_generator.py +1065 -0
- crackerjack/dynamic_config.py +678 -0
- crackerjack/errors.py +378 -0
- crackerjack/events/README.md +11 -0
- crackerjack/events/__init__.py +16 -0
- crackerjack/events/telemetry.py +175 -0
- crackerjack/events/workflow_bus.py +346 -0
- crackerjack/exceptions/README.md +301 -0
- crackerjack/exceptions/__init__.py +5 -0
- crackerjack/exceptions/config.py +4 -0
- crackerjack/exceptions/tool_execution_error.py +245 -0
- crackerjack/executors/README.md +591 -0
- crackerjack/executors/__init__.py +13 -0
- crackerjack/executors/async_hook_executor.py +938 -0
- crackerjack/executors/cached_hook_executor.py +316 -0
- crackerjack/executors/hook_executor.py +1295 -0
- crackerjack/executors/hook_lock_manager.py +708 -0
- crackerjack/executors/individual_hook_executor.py +739 -0
- crackerjack/executors/lsp_aware_hook_executor.py +349 -0
- crackerjack/executors/progress_hook_executor.py +282 -0
- crackerjack/executors/tool_proxy.py +433 -0
- crackerjack/hooks/README.md +485 -0
- crackerjack/hooks/lsp_hook.py +93 -0
- crackerjack/intelligence/README.md +557 -0
- crackerjack/intelligence/__init__.py +37 -0
- crackerjack/intelligence/adaptive_learning.py +693 -0
- crackerjack/intelligence/agent_orchestrator.py +485 -0
- crackerjack/intelligence/agent_registry.py +377 -0
- crackerjack/intelligence/agent_selector.py +439 -0
- crackerjack/intelligence/integration.py +250 -0
- crackerjack/interactive.py +719 -0
- crackerjack/managers/README.md +369 -0
- crackerjack/managers/__init__.py +11 -0
- crackerjack/managers/async_hook_manager.py +135 -0
- crackerjack/managers/hook_manager.py +585 -0
- crackerjack/managers/publish_manager.py +631 -0
- crackerjack/managers/test_command_builder.py +391 -0
- crackerjack/managers/test_executor.py +474 -0
- crackerjack/managers/test_manager.py +1357 -0
- crackerjack/managers/test_progress.py +187 -0
- crackerjack/mcp/README.md +374 -0
- crackerjack/mcp/__init__.py +0 -0
- crackerjack/mcp/cache.py +352 -0
- crackerjack/mcp/client_runner.py +121 -0
- crackerjack/mcp/context.py +802 -0
- crackerjack/mcp/dashboard.py +657 -0
- crackerjack/mcp/enhanced_progress_monitor.py +493 -0
- crackerjack/mcp/file_monitor.py +394 -0
- crackerjack/mcp/progress_components.py +607 -0
- crackerjack/mcp/progress_monitor.py +1016 -0
- crackerjack/mcp/rate_limiter.py +336 -0
- crackerjack/mcp/server.py +24 -0
- crackerjack/mcp/server_core.py +526 -0
- crackerjack/mcp/service_watchdog.py +505 -0
- crackerjack/mcp/state.py +407 -0
- crackerjack/mcp/task_manager.py +259 -0
- crackerjack/mcp/tools/README.md +27 -0
- crackerjack/mcp/tools/__init__.py +19 -0
- crackerjack/mcp/tools/core_tools.py +469 -0
- crackerjack/mcp/tools/error_analyzer.py +283 -0
- crackerjack/mcp/tools/execution_tools.py +384 -0
- crackerjack/mcp/tools/intelligence_tool_registry.py +46 -0
- crackerjack/mcp/tools/intelligence_tools.py +264 -0
- crackerjack/mcp/tools/monitoring_tools.py +628 -0
- crackerjack/mcp/tools/proactive_tools.py +367 -0
- crackerjack/mcp/tools/progress_tools.py +222 -0
- crackerjack/mcp/tools/semantic_tools.py +584 -0
- crackerjack/mcp/tools/utility_tools.py +358 -0
- crackerjack/mcp/tools/workflow_executor.py +699 -0
- crackerjack/mcp/websocket/README.md +31 -0
- crackerjack/mcp/websocket/__init__.py +14 -0
- crackerjack/mcp/websocket/app.py +54 -0
- crackerjack/mcp/websocket/endpoints.py +492 -0
- crackerjack/mcp/websocket/event_bridge.py +188 -0
- crackerjack/mcp/websocket/jobs.py +406 -0
- crackerjack/mcp/websocket/monitoring/__init__.py +25 -0
- crackerjack/mcp/websocket/monitoring/api/__init__.py +19 -0
- crackerjack/mcp/websocket/monitoring/api/dependencies.py +141 -0
- crackerjack/mcp/websocket/monitoring/api/heatmap.py +154 -0
- crackerjack/mcp/websocket/monitoring/api/intelligence.py +199 -0
- crackerjack/mcp/websocket/monitoring/api/metrics.py +203 -0
- crackerjack/mcp/websocket/monitoring/api/telemetry.py +101 -0
- crackerjack/mcp/websocket/monitoring/dashboard.py +18 -0
- crackerjack/mcp/websocket/monitoring/factory.py +109 -0
- crackerjack/mcp/websocket/monitoring/filters.py +10 -0
- crackerjack/mcp/websocket/monitoring/metrics.py +64 -0
- crackerjack/mcp/websocket/monitoring/models.py +90 -0
- crackerjack/mcp/websocket/monitoring/utils.py +171 -0
- crackerjack/mcp/websocket/monitoring/websocket_manager.py +78 -0
- crackerjack/mcp/websocket/monitoring/websockets/__init__.py +17 -0
- crackerjack/mcp/websocket/monitoring/websockets/dependencies.py +126 -0
- crackerjack/mcp/websocket/monitoring/websockets/heatmap.py +176 -0
- crackerjack/mcp/websocket/monitoring/websockets/intelligence.py +291 -0
- crackerjack/mcp/websocket/monitoring/websockets/metrics.py +291 -0
- crackerjack/mcp/websocket/monitoring_endpoints.py +21 -0
- crackerjack/mcp/websocket/server.py +174 -0
- crackerjack/mcp/websocket/websocket_handler.py +276 -0
- crackerjack/mcp/websocket_server.py +10 -0
- crackerjack/models/README.md +308 -0
- crackerjack/models/__init__.py +40 -0
- crackerjack/models/config.py +730 -0
- crackerjack/models/config_adapter.py +265 -0
- crackerjack/models/protocols.py +1535 -0
- crackerjack/models/pydantic_models.py +320 -0
- crackerjack/models/qa_config.py +145 -0
- crackerjack/models/qa_results.py +134 -0
- crackerjack/models/resource_protocols.py +299 -0
- crackerjack/models/results.py +35 -0
- crackerjack/models/semantic_models.py +258 -0
- crackerjack/models/task.py +173 -0
- crackerjack/models/test_models.py +60 -0
- crackerjack/monitoring/README.md +11 -0
- crackerjack/monitoring/__init__.py +0 -0
- crackerjack/monitoring/ai_agent_watchdog.py +405 -0
- crackerjack/monitoring/metrics_collector.py +427 -0
- crackerjack/monitoring/regression_prevention.py +580 -0
- crackerjack/monitoring/websocket_server.py +406 -0
- crackerjack/orchestration/README.md +340 -0
- crackerjack/orchestration/__init__.py +43 -0
- crackerjack/orchestration/advanced_orchestrator.py +894 -0
- crackerjack/orchestration/cache/README.md +312 -0
- crackerjack/orchestration/cache/__init__.py +37 -0
- crackerjack/orchestration/cache/memory_cache.py +338 -0
- crackerjack/orchestration/cache/tool_proxy_cache.py +340 -0
- crackerjack/orchestration/config.py +297 -0
- crackerjack/orchestration/coverage_improvement.py +180 -0
- crackerjack/orchestration/execution_strategies.py +361 -0
- crackerjack/orchestration/hook_orchestrator.py +1398 -0
- crackerjack/orchestration/strategies/README.md +401 -0
- crackerjack/orchestration/strategies/__init__.py +39 -0
- crackerjack/orchestration/strategies/adaptive_strategy.py +630 -0
- crackerjack/orchestration/strategies/parallel_strategy.py +237 -0
- crackerjack/orchestration/strategies/sequential_strategy.py +299 -0
- crackerjack/orchestration/test_progress_streamer.py +647 -0
- crackerjack/plugins/README.md +11 -0
- crackerjack/plugins/__init__.py +15 -0
- crackerjack/plugins/base.py +200 -0
- crackerjack/plugins/hooks.py +254 -0
- crackerjack/plugins/loader.py +335 -0
- crackerjack/plugins/managers.py +264 -0
- crackerjack/py313.py +191 -0
- crackerjack/security/README.md +11 -0
- crackerjack/security/__init__.py +0 -0
- crackerjack/security/audit.py +197 -0
- crackerjack/services/README.md +374 -0
- crackerjack/services/__init__.py +9 -0
- crackerjack/services/ai/README.md +295 -0
- crackerjack/services/ai/__init__.py +7 -0
- crackerjack/services/ai/advanced_optimizer.py +878 -0
- crackerjack/services/ai/contextual_ai_assistant.py +542 -0
- crackerjack/services/ai/embeddings.py +444 -0
- crackerjack/services/ai/intelligent_commit.py +328 -0
- crackerjack/services/ai/predictive_analytics.py +510 -0
- crackerjack/services/anomaly_detector.py +392 -0
- crackerjack/services/api_extractor.py +617 -0
- crackerjack/services/backup_service.py +467 -0
- crackerjack/services/bounded_status_operations.py +530 -0
- crackerjack/services/cache.py +369 -0
- crackerjack/services/changelog_automation.py +399 -0
- crackerjack/services/command_execution_service.py +305 -0
- crackerjack/services/config_integrity.py +132 -0
- crackerjack/services/config_merge.py +546 -0
- crackerjack/services/config_service.py +198 -0
- crackerjack/services/config_template.py +493 -0
- crackerjack/services/coverage_badge_service.py +173 -0
- crackerjack/services/coverage_ratchet.py +381 -0
- crackerjack/services/debug.py +733 -0
- crackerjack/services/dependency_analyzer.py +460 -0
- crackerjack/services/dependency_monitor.py +622 -0
- crackerjack/services/documentation_generator.py +493 -0
- crackerjack/services/documentation_service.py +704 -0
- crackerjack/services/enhanced_filesystem.py +497 -0
- crackerjack/services/enterprise_optimizer.py +865 -0
- crackerjack/services/error_pattern_analyzer.py +676 -0
- crackerjack/services/file_filter.py +221 -0
- crackerjack/services/file_hasher.py +149 -0
- crackerjack/services/file_io_service.py +361 -0
- crackerjack/services/file_modifier.py +615 -0
- crackerjack/services/filesystem.py +381 -0
- crackerjack/services/git.py +422 -0
- crackerjack/services/health_metrics.py +615 -0
- crackerjack/services/heatmap_generator.py +744 -0
- crackerjack/services/incremental_executor.py +380 -0
- crackerjack/services/initialization.py +823 -0
- crackerjack/services/input_validator.py +668 -0
- crackerjack/services/intelligent_commit.py +327 -0
- crackerjack/services/log_manager.py +289 -0
- crackerjack/services/logging.py +228 -0
- crackerjack/services/lsp_client.py +628 -0
- crackerjack/services/memory_optimizer.py +414 -0
- crackerjack/services/metrics.py +587 -0
- crackerjack/services/monitoring/README.md +30 -0
- crackerjack/services/monitoring/__init__.py +9 -0
- crackerjack/services/monitoring/dependency_monitor.py +678 -0
- crackerjack/services/monitoring/error_pattern_analyzer.py +676 -0
- crackerjack/services/monitoring/health_metrics.py +716 -0
- crackerjack/services/monitoring/metrics.py +587 -0
- crackerjack/services/monitoring/performance_benchmarks.py +410 -0
- crackerjack/services/monitoring/performance_cache.py +388 -0
- crackerjack/services/monitoring/performance_monitor.py +569 -0
- crackerjack/services/parallel_executor.py +527 -0
- crackerjack/services/pattern_cache.py +333 -0
- crackerjack/services/pattern_detector.py +478 -0
- crackerjack/services/patterns/__init__.py +142 -0
- crackerjack/services/patterns/agents.py +107 -0
- crackerjack/services/patterns/code/__init__.py +15 -0
- crackerjack/services/patterns/code/detection.py +118 -0
- crackerjack/services/patterns/code/imports.py +107 -0
- crackerjack/services/patterns/code/paths.py +159 -0
- crackerjack/services/patterns/code/performance.py +119 -0
- crackerjack/services/patterns/code/replacement.py +36 -0
- crackerjack/services/patterns/core.py +212 -0
- crackerjack/services/patterns/documentation/__init__.py +14 -0
- crackerjack/services/patterns/documentation/badges_markdown.py +96 -0
- crackerjack/services/patterns/documentation/comments_blocks.py +83 -0
- crackerjack/services/patterns/documentation/docstrings.py +89 -0
- crackerjack/services/patterns/formatting.py +226 -0
- crackerjack/services/patterns/operations.py +339 -0
- crackerjack/services/patterns/security/__init__.py +23 -0
- crackerjack/services/patterns/security/code_injection.py +122 -0
- crackerjack/services/patterns/security/credentials.py +190 -0
- crackerjack/services/patterns/security/path_traversal.py +221 -0
- crackerjack/services/patterns/security/unsafe_operations.py +216 -0
- crackerjack/services/patterns/templates.py +62 -0
- crackerjack/services/patterns/testing/__init__.py +18 -0
- crackerjack/services/patterns/testing/error_patterns.py +107 -0
- crackerjack/services/patterns/testing/pytest_output.py +126 -0
- crackerjack/services/patterns/tool_output/__init__.py +16 -0
- crackerjack/services/patterns/tool_output/bandit.py +72 -0
- crackerjack/services/patterns/tool_output/other.py +97 -0
- crackerjack/services/patterns/tool_output/pyright.py +67 -0
- crackerjack/services/patterns/tool_output/ruff.py +44 -0
- crackerjack/services/patterns/url_sanitization.py +114 -0
- crackerjack/services/patterns/utilities.py +42 -0
- crackerjack/services/patterns/utils.py +339 -0
- crackerjack/services/patterns/validation.py +46 -0
- crackerjack/services/patterns/versioning.py +62 -0
- crackerjack/services/predictive_analytics.py +523 -0
- crackerjack/services/profiler.py +280 -0
- crackerjack/services/quality/README.md +415 -0
- crackerjack/services/quality/__init__.py +11 -0
- crackerjack/services/quality/anomaly_detector.py +392 -0
- crackerjack/services/quality/pattern_cache.py +333 -0
- crackerjack/services/quality/pattern_detector.py +479 -0
- crackerjack/services/quality/qa_orchestrator.py +491 -0
- crackerjack/services/quality/quality_baseline.py +395 -0
- crackerjack/services/quality/quality_baseline_enhanced.py +649 -0
- crackerjack/services/quality/quality_intelligence.py +949 -0
- crackerjack/services/regex_patterns.py +58 -0
- crackerjack/services/regex_utils.py +483 -0
- crackerjack/services/secure_path_utils.py +524 -0
- crackerjack/services/secure_status_formatter.py +450 -0
- crackerjack/services/secure_subprocess.py +635 -0
- crackerjack/services/security.py +239 -0
- crackerjack/services/security_logger.py +495 -0
- crackerjack/services/server_manager.py +411 -0
- crackerjack/services/smart_scheduling.py +167 -0
- crackerjack/services/status_authentication.py +460 -0
- crackerjack/services/status_security_manager.py +315 -0
- crackerjack/services/terminal_utils.py +0 -0
- crackerjack/services/thread_safe_status_collector.py +441 -0
- crackerjack/services/tool_filter.py +368 -0
- crackerjack/services/tool_version_service.py +43 -0
- crackerjack/services/unified_config.py +115 -0
- crackerjack/services/validation_rate_limiter.py +220 -0
- crackerjack/services/vector_store.py +689 -0
- crackerjack/services/version_analyzer.py +461 -0
- crackerjack/services/version_checker.py +223 -0
- crackerjack/services/websocket_resource_limiter.py +438 -0
- crackerjack/services/zuban_lsp_service.py +391 -0
- crackerjack/slash_commands/README.md +11 -0
- crackerjack/slash_commands/__init__.py +59 -0
- crackerjack/slash_commands/init.md +112 -0
- crackerjack/slash_commands/run.md +197 -0
- crackerjack/slash_commands/status.md +127 -0
- crackerjack/tools/README.md +11 -0
- crackerjack/tools/__init__.py +30 -0
- crackerjack/tools/_git_utils.py +105 -0
- crackerjack/tools/check_added_large_files.py +139 -0
- crackerjack/tools/check_ast.py +105 -0
- crackerjack/tools/check_json.py +103 -0
- crackerjack/tools/check_jsonschema.py +297 -0
- crackerjack/tools/check_toml.py +103 -0
- crackerjack/tools/check_yaml.py +110 -0
- crackerjack/tools/codespell_wrapper.py +72 -0
- crackerjack/tools/end_of_file_fixer.py +202 -0
- crackerjack/tools/format_json.py +128 -0
- crackerjack/tools/mdformat_wrapper.py +114 -0
- crackerjack/tools/trailing_whitespace.py +198 -0
- crackerjack/tools/validate_input_validator_patterns.py +236 -0
- crackerjack/tools/validate_regex_patterns.py +188 -0
- crackerjack/ui/README.md +11 -0
- crackerjack/ui/__init__.py +1 -0
- crackerjack/ui/dashboard_renderer.py +28 -0
- crackerjack/ui/templates/README.md +11 -0
- crackerjack/utils/console_utils.py +13 -0
- crackerjack/utils/dependency_guard.py +230 -0
- crackerjack/utils/retry_utils.py +275 -0
- crackerjack/workflows/README.md +590 -0
- crackerjack/workflows/__init__.py +46 -0
- crackerjack/workflows/actions.py +811 -0
- crackerjack/workflows/auto_fix.py +444 -0
- crackerjack/workflows/container_builder.py +499 -0
- crackerjack/workflows/definitions.py +443 -0
- crackerjack/workflows/engine.py +177 -0
- crackerjack/workflows/event_bridge.py +242 -0
- crackerjack-0.45.2.dist-info/METADATA +1678 -0
- crackerjack-0.45.2.dist-info/RECORD +478 -0
- {crackerjack-0.18.2.dist-info → crackerjack-0.45.2.dist-info}/WHEEL +1 -1
- crackerjack-0.45.2.dist-info/entry_points.txt +2 -0
- crackerjack/.gitignore +0 -14
- crackerjack/.libcst.codemod.yaml +0 -18
- crackerjack/.pdm.toml +0 -1
- crackerjack/.pre-commit-config.yaml +0 -91
- crackerjack/.pytest_cache/.gitignore +0 -2
- crackerjack/.pytest_cache/CACHEDIR.TAG +0 -4
- crackerjack/.pytest_cache/README.md +0 -8
- crackerjack/.pytest_cache/v/cache/nodeids +0 -1
- crackerjack/.pytest_cache/v/cache/stepwise +0 -1
- crackerjack/.ruff_cache/.gitignore +0 -1
- crackerjack/.ruff_cache/0.1.11/3256171999636029978 +0 -0
- crackerjack/.ruff_cache/0.1.14/602324811142551221 +0 -0
- crackerjack/.ruff_cache/0.1.4/10355199064880463147 +0 -0
- crackerjack/.ruff_cache/0.1.6/15140459877605758699 +0 -0
- crackerjack/.ruff_cache/0.1.7/1790508110482614856 +0 -0
- crackerjack/.ruff_cache/0.1.9/17041001205004563469 +0 -0
- crackerjack/.ruff_cache/0.11.2/4070660268492669020 +0 -0
- crackerjack/.ruff_cache/0.11.3/9818742842212983150 +0 -0
- crackerjack/.ruff_cache/0.11.4/9818742842212983150 +0 -0
- crackerjack/.ruff_cache/0.11.6/3557596832929915217 +0 -0
- crackerjack/.ruff_cache/0.11.7/10386934055395314831 +0 -0
- crackerjack/.ruff_cache/0.11.7/3557596832929915217 +0 -0
- crackerjack/.ruff_cache/0.11.8/530407680854991027 +0 -0
- crackerjack/.ruff_cache/0.2.0/10047773857155985907 +0 -0
- crackerjack/.ruff_cache/0.2.1/8522267973936635051 +0 -0
- crackerjack/.ruff_cache/0.2.2/18053836298936336950 +0 -0
- crackerjack/.ruff_cache/0.3.0/12548816621480535786 +0 -0
- crackerjack/.ruff_cache/0.3.3/11081883392474770722 +0 -0
- crackerjack/.ruff_cache/0.3.4/676973378459347183 +0 -0
- crackerjack/.ruff_cache/0.3.5/16311176246009842383 +0 -0
- crackerjack/.ruff_cache/0.5.7/1493622539551733492 +0 -0
- crackerjack/.ruff_cache/0.5.7/6231957614044513175 +0 -0
- crackerjack/.ruff_cache/0.5.7/9932762556785938009 +0 -0
- crackerjack/.ruff_cache/0.6.0/11982804814124138945 +0 -0
- crackerjack/.ruff_cache/0.6.0/12055761203849489982 +0 -0
- crackerjack/.ruff_cache/0.6.2/1206147804896221174 +0 -0
- crackerjack/.ruff_cache/0.6.4/1206147804896221174 +0 -0
- crackerjack/.ruff_cache/0.6.5/1206147804896221174 +0 -0
- crackerjack/.ruff_cache/0.6.7/3657366982708166874 +0 -0
- crackerjack/.ruff_cache/0.6.9/285614542852677309 +0 -0
- crackerjack/.ruff_cache/0.7.1/1024065805990144819 +0 -0
- crackerjack/.ruff_cache/0.7.1/285614542852677309 +0 -0
- crackerjack/.ruff_cache/0.7.3/16061516852537040135 +0 -0
- crackerjack/.ruff_cache/0.8.4/16354268377385700367 +0 -0
- crackerjack/.ruff_cache/0.9.10/12813592349865671909 +0 -0
- crackerjack/.ruff_cache/0.9.10/923908772239632759 +0 -0
- crackerjack/.ruff_cache/0.9.3/13948373885254993391 +0 -0
- crackerjack/.ruff_cache/0.9.9/12813592349865671909 +0 -0
- crackerjack/.ruff_cache/0.9.9/8843823720003377982 +0 -0
- crackerjack/.ruff_cache/CACHEDIR.TAG +0 -1
- crackerjack/crackerjack.py +0 -855
- crackerjack/pyproject.toml +0 -214
- crackerjack-0.18.2.dist-info/METADATA +0 -420
- crackerjack-0.18.2.dist-info/RECORD +0 -59
- crackerjack-0.18.2.dist-info/entry_points.txt +0 -4
- {crackerjack-0.18.2.dist-info → crackerjack-0.45.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,756 @@
|
|
|
1
|
+
"""AI template engine for structured documentation generation.
|
|
2
|
+
|
|
3
|
+
This module provides intelligent template generation and processing for AI-optimized
|
|
4
|
+
documentation, including context-aware content generation and template inheritance.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
import re
|
|
9
|
+
import typing as t
|
|
10
|
+
from dataclasses import dataclass, field
|
|
11
|
+
from datetime import datetime
|
|
12
|
+
from enum import Enum
|
|
13
|
+
|
|
14
|
+
from ..models.protocols import (
|
|
15
|
+
ConfigManagerProtocol,
|
|
16
|
+
LoggerProtocol,
|
|
17
|
+
)
|
|
18
|
+
from ..services.regex_patterns import SAFE_PATTERNS
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class TemplateType(Enum):
|
|
22
|
+
"""Types of documentation templates."""
|
|
23
|
+
|
|
24
|
+
AI_REFERENCE = "ai_reference"
|
|
25
|
+
USER_GUIDE = "user_guide"
|
|
26
|
+
API_REFERENCE = "api_reference"
|
|
27
|
+
CHANGELOG = "changelog"
|
|
28
|
+
README = "readme"
|
|
29
|
+
TROUBLESHOOTING = "troubleshooting"
|
|
30
|
+
QUICK_START = "quick_start"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass
|
|
34
|
+
class TemplateContext:
|
|
35
|
+
"""Context data for template rendering."""
|
|
36
|
+
|
|
37
|
+
# Project metadata
|
|
38
|
+
project_name: str
|
|
39
|
+
project_description: str
|
|
40
|
+
version: str
|
|
41
|
+
author: str
|
|
42
|
+
|
|
43
|
+
# Documentation metadata
|
|
44
|
+
generated_at: datetime = field(default_factory=datetime.now)
|
|
45
|
+
template_type: TemplateType | None = None
|
|
46
|
+
|
|
47
|
+
# Dynamic content
|
|
48
|
+
variables: dict[str, t.Any] = field(default_factory=dict[str, t.Any])
|
|
49
|
+
sections: dict[str, str] = field(default_factory=dict[str, t.Any])
|
|
50
|
+
|
|
51
|
+
# AI-specific context
|
|
52
|
+
ai_optimization_level: str = "standard" # minimal, standard, comprehensive
|
|
53
|
+
target_audience: str = "developers" # developers, users, maintainers
|
|
54
|
+
|
|
55
|
+
def get_variable(self, key: str, default: t.Any = None) -> t.Any:
|
|
56
|
+
"""Get a template variable with default fallback."""
|
|
57
|
+
return self.variables.get(key, default)
|
|
58
|
+
|
|
59
|
+
def set_variable(self, key: str, value: t.Any) -> None:
|
|
60
|
+
"""Set a template variable."""
|
|
61
|
+
self.variables[key] = value
|
|
62
|
+
|
|
63
|
+
def get_section(self, name: str, default: str = "") -> str:
|
|
64
|
+
"""Get a template section with default fallback."""
|
|
65
|
+
return self.sections.get(name, default)
|
|
66
|
+
|
|
67
|
+
def set_section(self, name: str, content: str) -> None:
|
|
68
|
+
"""Set a template section."""
|
|
69
|
+
self.sections[name] = content
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@dataclass
|
|
73
|
+
class Template:
|
|
74
|
+
"""Represents a documentation template."""
|
|
75
|
+
|
|
76
|
+
name: str
|
|
77
|
+
content: str
|
|
78
|
+
template_type: TemplateType
|
|
79
|
+
variables: list[str] = field(default_factory=list)
|
|
80
|
+
sections: list[str] = field(default_factory=list)
|
|
81
|
+
parent_template: str | None = None
|
|
82
|
+
ai_optimizations: dict[str, t.Any] = field(default_factory=dict[str, t.Any])
|
|
83
|
+
|
|
84
|
+
def extract_placeholders(self) -> tuple[list[str], list[str]]:
|
|
85
|
+
"""Extract variable and section placeholders from template content.
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
Tuple of (variables, sections) found in template
|
|
89
|
+
"""
|
|
90
|
+
# Find {{variable}} patterns
|
|
91
|
+
var_pattern = SAFE_PATTERNS[
|
|
92
|
+
"extract_template_variables"
|
|
93
|
+
]._get_compiled_pattern()
|
|
94
|
+
variables = var_pattern.findall(self.content)
|
|
95
|
+
|
|
96
|
+
# Find {% section name %} patterns
|
|
97
|
+
section_pattern = SAFE_PATTERNS[
|
|
98
|
+
"extract_template_sections"
|
|
99
|
+
]._get_compiled_pattern()
|
|
100
|
+
sections = section_pattern.findall(self.content)
|
|
101
|
+
|
|
102
|
+
return list[t.Any](set[t.Any](variables)), list[t.Any](set[t.Any](sections))
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class AITemplateEngine:
|
|
106
|
+
"""Engine for processing AI-optimized documentation templates."""
|
|
107
|
+
|
|
108
|
+
def __init__(
|
|
109
|
+
self,
|
|
110
|
+
config_manager: ConfigManagerProtocol,
|
|
111
|
+
logger: LoggerProtocol,
|
|
112
|
+
):
|
|
113
|
+
self.config_manager = config_manager
|
|
114
|
+
self.logger = logger
|
|
115
|
+
self.templates: dict[str, Template] = {}
|
|
116
|
+
self.template_cache: dict[str, str] = {}
|
|
117
|
+
|
|
118
|
+
# Load built-in templates
|
|
119
|
+
self._load_builtin_templates()
|
|
120
|
+
|
|
121
|
+
def render_template(
|
|
122
|
+
self,
|
|
123
|
+
template_name: str,
|
|
124
|
+
context: TemplateContext,
|
|
125
|
+
) -> str:
|
|
126
|
+
"""Render a template with the given context.
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
template_name: Name of template to render
|
|
130
|
+
context: Template context with variables and sections
|
|
131
|
+
|
|
132
|
+
Returns:
|
|
133
|
+
Rendered template content
|
|
134
|
+
"""
|
|
135
|
+
if template_name not in self.templates:
|
|
136
|
+
raise ValueError(f"Template not found: {template_name}")
|
|
137
|
+
|
|
138
|
+
template = self.templates[template_name]
|
|
139
|
+
|
|
140
|
+
# Apply template inheritance if needed
|
|
141
|
+
content = self._apply_inheritance(template, context)
|
|
142
|
+
|
|
143
|
+
# Apply AI optimizations based on context
|
|
144
|
+
content = self._apply_ai_optimizations(content, template, context)
|
|
145
|
+
|
|
146
|
+
# Render variables
|
|
147
|
+
content = self._render_variables(content, context)
|
|
148
|
+
|
|
149
|
+
# Render sections
|
|
150
|
+
content = self._render_sections(content, context)
|
|
151
|
+
|
|
152
|
+
# Post-process content
|
|
153
|
+
content = self._post_process_content(content, context)
|
|
154
|
+
|
|
155
|
+
return content
|
|
156
|
+
|
|
157
|
+
def register_template(self, template: Template) -> None:
|
|
158
|
+
"""Register a new template.
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
template: Template to register
|
|
162
|
+
"""
|
|
163
|
+
# Extract placeholders
|
|
164
|
+
variables, sections = template.extract_placeholders()
|
|
165
|
+
template.variables = variables
|
|
166
|
+
template.sections = sections
|
|
167
|
+
|
|
168
|
+
self.templates[template.name] = template
|
|
169
|
+
self.logger.debug(f"Registered template: {template.name}")
|
|
170
|
+
|
|
171
|
+
def create_ai_reference_template(
|
|
172
|
+
self,
|
|
173
|
+
commands: dict[str, dict[str, t.Any]],
|
|
174
|
+
decision_trees: list[dict[str, t.Any]],
|
|
175
|
+
agent_capabilities: dict[str, dict[str, t.Any]],
|
|
176
|
+
) -> str:
|
|
177
|
+
"""Create AI-optimized reference template.
|
|
178
|
+
|
|
179
|
+
Args:
|
|
180
|
+
commands: Command definitions with metadata
|
|
181
|
+
decision_trees: Decision tree structures
|
|
182
|
+
agent_capabilities: Agent capability definitions
|
|
183
|
+
|
|
184
|
+
Returns:
|
|
185
|
+
AI reference template content
|
|
186
|
+
"""
|
|
187
|
+
context = TemplateContext(
|
|
188
|
+
project_name="{{project_name}}",
|
|
189
|
+
project_description="{{project_description}}",
|
|
190
|
+
version="{{version}}",
|
|
191
|
+
author="{{author}}",
|
|
192
|
+
template_type=TemplateType.AI_REFERENCE,
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
context.set_variable("commands", commands)
|
|
196
|
+
context.set_variable("decision_trees", decision_trees)
|
|
197
|
+
context.set_variable("agent_capabilities", agent_capabilities)
|
|
198
|
+
|
|
199
|
+
return self.render_template("ai_reference_base", context)
|
|
200
|
+
|
|
201
|
+
def create_user_guide_template(
|
|
202
|
+
self,
|
|
203
|
+
workflows: list[dict[str, t.Any]],
|
|
204
|
+
examples: list[dict[str, str]],
|
|
205
|
+
troubleshooting: dict[str, str],
|
|
206
|
+
) -> str:
|
|
207
|
+
"""Create user-friendly guide template.
|
|
208
|
+
|
|
209
|
+
Args:
|
|
210
|
+
workflows: Workflow definitions
|
|
211
|
+
examples: Example code/commands
|
|
212
|
+
troubleshooting: Common issues and solutions
|
|
213
|
+
|
|
214
|
+
Returns:
|
|
215
|
+
User guide template content
|
|
216
|
+
"""
|
|
217
|
+
context = TemplateContext(
|
|
218
|
+
project_name="{{project_name}}",
|
|
219
|
+
project_description="{{project_description}}",
|
|
220
|
+
version="{{version}}",
|
|
221
|
+
author="{{author}}",
|
|
222
|
+
template_type=TemplateType.USER_GUIDE,
|
|
223
|
+
target_audience="users",
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
context.set_variable("workflows", workflows)
|
|
227
|
+
context.set_variable("examples", examples)
|
|
228
|
+
context.set_variable("troubleshooting", troubleshooting)
|
|
229
|
+
|
|
230
|
+
return self.render_template("user_guide_base", context)
|
|
231
|
+
|
|
232
|
+
def _load_builtin_templates(self) -> None:
|
|
233
|
+
"""Load built-in template definitions."""
|
|
234
|
+
# AI Reference Base Template
|
|
235
|
+
ai_ref_template = Template(
|
|
236
|
+
name="ai_reference_base",
|
|
237
|
+
template_type=TemplateType.AI_REFERENCE,
|
|
238
|
+
content=self._get_ai_reference_template_content(),
|
|
239
|
+
ai_optimizations={
|
|
240
|
+
"structured_data": True,
|
|
241
|
+
"decision_trees": True,
|
|
242
|
+
"command_matrices": True,
|
|
243
|
+
"pattern_matching": True,
|
|
244
|
+
},
|
|
245
|
+
)
|
|
246
|
+
self.register_template(ai_ref_template)
|
|
247
|
+
|
|
248
|
+
# User Guide Base Template
|
|
249
|
+
user_guide_template = Template(
|
|
250
|
+
name="user_guide_base",
|
|
251
|
+
template_type=TemplateType.USER_GUIDE,
|
|
252
|
+
content=self._get_user_guide_template_content(),
|
|
253
|
+
ai_optimizations={
|
|
254
|
+
"step_by_step": True,
|
|
255
|
+
"visual_examples": True,
|
|
256
|
+
"progressive_disclosure": True,
|
|
257
|
+
},
|
|
258
|
+
)
|
|
259
|
+
self.register_template(user_guide_template)
|
|
260
|
+
|
|
261
|
+
# README Template
|
|
262
|
+
readme_template = Template(
|
|
263
|
+
name="readme_base",
|
|
264
|
+
template_type=TemplateType.README,
|
|
265
|
+
content=self._get_readme_template_content(),
|
|
266
|
+
ai_optimizations={
|
|
267
|
+
"quick_start": True,
|
|
268
|
+
"feature_highlights": True,
|
|
269
|
+
"installation_matrix": True,
|
|
270
|
+
},
|
|
271
|
+
)
|
|
272
|
+
self.register_template(readme_template)
|
|
273
|
+
|
|
274
|
+
# Changelog Template
|
|
275
|
+
changelog_template = Template(
|
|
276
|
+
name="changelog_base",
|
|
277
|
+
template_type=TemplateType.CHANGELOG,
|
|
278
|
+
content=self._get_changelog_template_content(),
|
|
279
|
+
ai_optimizations={
|
|
280
|
+
"semantic_versioning": True,
|
|
281
|
+
"categorized_changes": True,
|
|
282
|
+
"migration_guides": True,
|
|
283
|
+
},
|
|
284
|
+
)
|
|
285
|
+
self.register_template(changelog_template)
|
|
286
|
+
|
|
287
|
+
def _apply_inheritance(self, template: Template, context: TemplateContext) -> str:
|
|
288
|
+
"""Apply template inheritance if parent template exists.
|
|
289
|
+
|
|
290
|
+
Args:
|
|
291
|
+
template: Template to process
|
|
292
|
+
context: Template context
|
|
293
|
+
|
|
294
|
+
Returns:
|
|
295
|
+
Content with inheritance applied
|
|
296
|
+
"""
|
|
297
|
+
if not template.parent_template:
|
|
298
|
+
return template.content
|
|
299
|
+
|
|
300
|
+
parent = self.templates.get(template.parent_template)
|
|
301
|
+
if not parent:
|
|
302
|
+
self.logger.warning(
|
|
303
|
+
f"Parent template not found: {template.parent_template}"
|
|
304
|
+
)
|
|
305
|
+
return template.content
|
|
306
|
+
|
|
307
|
+
# Simple block replacement inheritance
|
|
308
|
+
parent_content = parent.content
|
|
309
|
+
|
|
310
|
+
# Find blocks in child template
|
|
311
|
+
block_pattern = SAFE_PATTERNS["extract_template_blocks"]._get_compiled_pattern()
|
|
312
|
+
blocks = block_pattern.findall(template.content)
|
|
313
|
+
|
|
314
|
+
# Replace blocks in parent content
|
|
315
|
+
for block_name, block_content in blocks:
|
|
316
|
+
# Create dynamic pattern for specific block replacement
|
|
317
|
+
dynamic_pattern = SAFE_PATTERNS["replace_template_block"].pattern.replace(
|
|
318
|
+
"BLOCK_NAME", block_name
|
|
319
|
+
)
|
|
320
|
+
parent_content = (
|
|
321
|
+
re.sub( # REGEX OK: safe dynamic pattern from SAFE_PATTERNS
|
|
322
|
+
dynamic_pattern,
|
|
323
|
+
block_content.strip(),
|
|
324
|
+
parent_content,
|
|
325
|
+
flags=re.DOTALL,
|
|
326
|
+
)
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
return parent_content
|
|
330
|
+
|
|
331
|
+
def _apply_ai_optimizations(
|
|
332
|
+
self,
|
|
333
|
+
content: str,
|
|
334
|
+
template: Template,
|
|
335
|
+
context: TemplateContext,
|
|
336
|
+
) -> str:
|
|
337
|
+
"""Apply AI-specific optimizations to content.
|
|
338
|
+
|
|
339
|
+
Args:
|
|
340
|
+
content: Template content
|
|
341
|
+
template: Template definition
|
|
342
|
+
context: Render context
|
|
343
|
+
|
|
344
|
+
Returns:
|
|
345
|
+
Optimized content
|
|
346
|
+
"""
|
|
347
|
+
optimizations = template.ai_optimizations
|
|
348
|
+
|
|
349
|
+
# Structured data optimization
|
|
350
|
+
if optimizations.get("structured_data"):
|
|
351
|
+
content = self._optimize_for_structured_data(content, context)
|
|
352
|
+
|
|
353
|
+
# Decision tree optimization
|
|
354
|
+
if optimizations.get("decision_trees"):
|
|
355
|
+
content = self._optimize_for_decision_trees(content, context)
|
|
356
|
+
|
|
357
|
+
# Command matrix optimization
|
|
358
|
+
if optimizations.get("command_matrices"):
|
|
359
|
+
content = self._optimize_for_command_matrices(content, context)
|
|
360
|
+
|
|
361
|
+
# Step-by-step optimization
|
|
362
|
+
if optimizations.get("step_by_step"):
|
|
363
|
+
content = self._optimize_for_step_by_step(content, context)
|
|
364
|
+
|
|
365
|
+
return content
|
|
366
|
+
|
|
367
|
+
def _render_variables(self, content: str, context: TemplateContext) -> str:
|
|
368
|
+
"""Render template variables in content.
|
|
369
|
+
|
|
370
|
+
Args:
|
|
371
|
+
content: Content with variable placeholders
|
|
372
|
+
context: Template context
|
|
373
|
+
|
|
374
|
+
Returns:
|
|
375
|
+
Content with variables rendered
|
|
376
|
+
"""
|
|
377
|
+
# Render basic project variables
|
|
378
|
+
replacements = {
|
|
379
|
+
"project_name": context.project_name,
|
|
380
|
+
"project_description": context.project_description,
|
|
381
|
+
"version": context.version,
|
|
382
|
+
"author": context.author,
|
|
383
|
+
"generated_at": context.generated_at.strftime("%Y-%m-%d %H:%M:%S"),
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
# Add custom variables
|
|
387
|
+
replacements.update(context.variables)
|
|
388
|
+
|
|
389
|
+
# Replace variables
|
|
390
|
+
for var_name, value in replacements.items():
|
|
391
|
+
placeholder = f"{{{{{var_name}}}}}"
|
|
392
|
+
# Check if value is a complex type (dict[str, t.Any] or list[t.Any]) that needs JSON serialization
|
|
393
|
+
if isinstance(value, dict | list):
|
|
394
|
+
# For complex data, use JSON representation
|
|
395
|
+
value_str = json.dumps(value, indent=2)
|
|
396
|
+
else:
|
|
397
|
+
value_str = value
|
|
398
|
+
|
|
399
|
+
content = content.replace(placeholder, value_str)
|
|
400
|
+
|
|
401
|
+
return content
|
|
402
|
+
|
|
403
|
+
def _render_sections(self, content: str, context: TemplateContext) -> str:
|
|
404
|
+
"""Render template sections in content.
|
|
405
|
+
|
|
406
|
+
Args:
|
|
407
|
+
content: Content with section placeholders
|
|
408
|
+
context: Template context
|
|
409
|
+
|
|
410
|
+
Returns:
|
|
411
|
+
Content with sections rendered
|
|
412
|
+
"""
|
|
413
|
+
# Find section placeholders
|
|
414
|
+
section_pattern = SAFE_PATTERNS[
|
|
415
|
+
"extract_template_sections"
|
|
416
|
+
]._get_compiled_pattern()
|
|
417
|
+
|
|
418
|
+
def replace_section(match: t.Any) -> str:
|
|
419
|
+
section_name = match.group(1)
|
|
420
|
+
return context.get_section(
|
|
421
|
+
section_name, f"<!-- Section {section_name} not found -->"
|
|
422
|
+
)
|
|
423
|
+
|
|
424
|
+
return section_pattern.sub(replace_section, content)
|
|
425
|
+
|
|
426
|
+
def _post_process_content(self, content: str, context: TemplateContext) -> str:
|
|
427
|
+
"""Post-process rendered content for final cleanup.
|
|
428
|
+
|
|
429
|
+
Args:
|
|
430
|
+
content: Rendered content
|
|
431
|
+
context: Template context
|
|
432
|
+
|
|
433
|
+
Returns:
|
|
434
|
+
Post-processed content
|
|
435
|
+
"""
|
|
436
|
+
# Remove empty lines and normalize whitespace
|
|
437
|
+
lines = content.split("\n")
|
|
438
|
+
processed_lines = []
|
|
439
|
+
|
|
440
|
+
for line in lines:
|
|
441
|
+
# Remove trailing whitespace
|
|
442
|
+
line = line.rstrip()
|
|
443
|
+
processed_lines.append(line)
|
|
444
|
+
|
|
445
|
+
# Join lines and normalize multiple blank lines
|
|
446
|
+
content = "\n".join(processed_lines)
|
|
447
|
+
content = SAFE_PATTERNS["normalize_multiple_newlines"].apply(content)
|
|
448
|
+
|
|
449
|
+
return content.strip()
|
|
450
|
+
|
|
451
|
+
def _optimize_for_structured_data(
|
|
452
|
+
self, content: str, context: TemplateContext
|
|
453
|
+
) -> str:
|
|
454
|
+
"""Optimize content for structured data consumption by AI.
|
|
455
|
+
|
|
456
|
+
Args:
|
|
457
|
+
content: Content to optimize
|
|
458
|
+
context: Template context
|
|
459
|
+
|
|
460
|
+
Returns:
|
|
461
|
+
AI-optimized content
|
|
462
|
+
"""
|
|
463
|
+
# Add structured metadata at the beginning
|
|
464
|
+
metadata = f"""<!-- AI-Optimized Documentation -->
|
|
465
|
+
<!-- Generated: {context.generated_at.isoformat()} -->
|
|
466
|
+
<!-- Target Audience: {context.target_audience} -->
|
|
467
|
+
<!-- Optimization Level: {context.ai_optimization_level} -->
|
|
468
|
+
|
|
469
|
+
"""
|
|
470
|
+
return metadata + content
|
|
471
|
+
|
|
472
|
+
def _optimize_for_decision_trees(
|
|
473
|
+
self, content: str, context: TemplateContext
|
|
474
|
+
) -> str:
|
|
475
|
+
"""Optimize content for decision tree representation.
|
|
476
|
+
|
|
477
|
+
Args:
|
|
478
|
+
content: Content to optimize
|
|
479
|
+
context: Template context
|
|
480
|
+
|
|
481
|
+
Returns:
|
|
482
|
+
Decision tree optimized content
|
|
483
|
+
"""
|
|
484
|
+
# Add decision tree markers for AI parsing
|
|
485
|
+
# This helps AI assistants identify decision points
|
|
486
|
+
decision_markers = {
|
|
487
|
+
"if": "🔄 **Decision Point**:",
|
|
488
|
+
"when": "⚡ **Trigger Condition**:",
|
|
489
|
+
"use": "✅ **Recommended Action**:",
|
|
490
|
+
"avoid": "❌ **Avoid This**:",
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
for marker, prefix in decision_markers.items():
|
|
494
|
+
# Create safe dynamic pattern for each decision marker
|
|
495
|
+
pattern = rf"^(\s*)(.*{re.escape(marker)}.*)$"
|
|
496
|
+
content = re.sub( # REGEX OK: escaped marker pattern, safe dynamic
|
|
497
|
+
pattern, rf"\1{prefix} \2", content, flags=re.MULTILINE | re.IGNORECASE
|
|
498
|
+
)
|
|
499
|
+
|
|
500
|
+
return content
|
|
501
|
+
|
|
502
|
+
def _optimize_for_command_matrices(
|
|
503
|
+
self, content: str, context: TemplateContext
|
|
504
|
+
) -> str:
|
|
505
|
+
"""Optimize content for command matrix representation.
|
|
506
|
+
|
|
507
|
+
Args:
|
|
508
|
+
content: Content to optimize
|
|
509
|
+
context: Template context
|
|
510
|
+
|
|
511
|
+
Returns:
|
|
512
|
+
Command matrix optimized content
|
|
513
|
+
"""
|
|
514
|
+
|
|
515
|
+
# Add command execution markers
|
|
516
|
+
def enhance_command_block(match: t.Any) -> str:
|
|
517
|
+
command = match.group(1).strip()
|
|
518
|
+
return f"""```bash
|
|
519
|
+
# Command: {command.split()[0] if command.split() else "unknown"}
|
|
520
|
+
{command}
|
|
521
|
+
```"""
|
|
522
|
+
|
|
523
|
+
command_pattern = SAFE_PATTERNS[
|
|
524
|
+
"extract_bash_command_blocks"
|
|
525
|
+
]._get_compiled_pattern()
|
|
526
|
+
return command_pattern.sub(enhance_command_block, content)
|
|
527
|
+
|
|
528
|
+
def _optimize_for_step_by_step(self, content: str, context: TemplateContext) -> str:
|
|
529
|
+
"""Optimize content for step-by-step processing.
|
|
530
|
+
|
|
531
|
+
Args:
|
|
532
|
+
content: Content to optimize
|
|
533
|
+
context: Template context
|
|
534
|
+
|
|
535
|
+
Returns:
|
|
536
|
+
Step-by-step optimized content
|
|
537
|
+
"""
|
|
538
|
+
# Add step markers to numbered lists
|
|
539
|
+
step_pattern = SAFE_PATTERNS["extract_step_numbers"]._get_compiled_pattern()
|
|
540
|
+
|
|
541
|
+
def enhance_step(match: t.Any) -> str:
|
|
542
|
+
indent, number, text = match.groups()
|
|
543
|
+
return f"{indent}**Step {number}**: {text}"
|
|
544
|
+
|
|
545
|
+
return step_pattern.sub(enhance_step, content)
|
|
546
|
+
|
|
547
|
+
def _get_ai_reference_template_content(self) -> str:
|
|
548
|
+
"""Get AI reference template content."""
|
|
549
|
+
return """# {{project_name}} AI Reference
|
|
550
|
+
|
|
551
|
+
**AI-Optimized Reference for {{project_name}} Architecture and Commands**
|
|
552
|
+
|
|
553
|
+
Generated: {{generated_at}}
|
|
554
|
+
Version: {{version}}
|
|
555
|
+
|
|
556
|
+
## Quick Command Matrix
|
|
557
|
+
|
|
558
|
+
### Primary Workflows
|
|
559
|
+
|
|
560
|
+
| Command | Use Case | AI Context | Success Pattern |
|
|
561
|
+
|---------|----------|-------------|--------------------|
|
|
562
|
+
{% section command_matrix %}
|
|
563
|
+
|
|
564
|
+
## AI Decision Trees
|
|
565
|
+
|
|
566
|
+
```mermaid
|
|
567
|
+
graph TD
|
|
568
|
+
{% section decision_trees %}
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
## Agent Selection Matrix
|
|
572
|
+
|
|
573
|
+
### By Issue Type
|
|
574
|
+
|
|
575
|
+
| Issue Pattern | Best Agent | Confidence | Command Pattern |
|
|
576
|
+
|---------------|------------|------------|--------------------|
|
|
577
|
+
{% section agent_matrix %}
|
|
578
|
+
|
|
579
|
+
## Error Pattern Library
|
|
580
|
+
|
|
581
|
+
### Common Patterns
|
|
582
|
+
|
|
583
|
+
{% section error_patterns %}
|
|
584
|
+
|
|
585
|
+
## Workflow Sequences
|
|
586
|
+
|
|
587
|
+
### Standard Development Cycle
|
|
588
|
+
|
|
589
|
+
{% section development_workflow %}
|
|
590
|
+
|
|
591
|
+
## Success Indicators
|
|
592
|
+
|
|
593
|
+
### Quality Check Success
|
|
594
|
+
|
|
595
|
+
{% section success_indicators %}
|
|
596
|
+
|
|
597
|
+
---
|
|
598
|
+
|
|
599
|
+
*This reference is AI-optimized for autonomous operation and quick decision making.*
|
|
600
|
+
"""
|
|
601
|
+
|
|
602
|
+
def _get_user_guide_template_content(self) -> str:
|
|
603
|
+
"""Get user guide template content."""
|
|
604
|
+
return """# {{project_name}} User Guide
|
|
605
|
+
|
|
606
|
+
Welcome to {{project_name}} - {{project_description}}
|
|
607
|
+
|
|
608
|
+
## Getting Started
|
|
609
|
+
|
|
610
|
+
### Installation
|
|
611
|
+
|
|
612
|
+
**Step 1**: Install {{project_name}}
|
|
613
|
+
```bash
|
|
614
|
+
pip install {{project_name}}
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
**Step 2**: Verify installation
|
|
618
|
+
```bash
|
|
619
|
+
{{project_name}} --version
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
### Quick Start
|
|
623
|
+
|
|
624
|
+
{% section quick_start %}
|
|
625
|
+
|
|
626
|
+
## Common Workflows
|
|
627
|
+
|
|
628
|
+
### Development Workflow
|
|
629
|
+
|
|
630
|
+
{% section development_workflow %}
|
|
631
|
+
|
|
632
|
+
### Release Workflow
|
|
633
|
+
|
|
634
|
+
{% section release_workflow %}
|
|
635
|
+
|
|
636
|
+
## Examples
|
|
637
|
+
|
|
638
|
+
{% section examples %}
|
|
639
|
+
|
|
640
|
+
## Troubleshooting
|
|
641
|
+
|
|
642
|
+
{% section troubleshooting %}
|
|
643
|
+
|
|
644
|
+
## Advanced Usage
|
|
645
|
+
|
|
646
|
+
{% section advanced_usage %}
|
|
647
|
+
|
|
648
|
+
---
|
|
649
|
+
|
|
650
|
+
For more information, see the [API Reference](api-reference.md) or visit our [GitHub repository]({{repo_url}}).
|
|
651
|
+
"""
|
|
652
|
+
|
|
653
|
+
def _get_readme_template_content(self) -> str:
|
|
654
|
+
"""Get README template content."""
|
|
655
|
+
return """# {{project_name}}
|
|
656
|
+
|
|
657
|
+
{{project_description}}
|
|
658
|
+
|
|
659
|
+
[]({{repo_url}})
|
|
660
|
+
[](https://python.org)
|
|
661
|
+
|
|
662
|
+
## Features
|
|
663
|
+
|
|
664
|
+
{% section features %}
|
|
665
|
+
|
|
666
|
+
## Quick Start
|
|
667
|
+
|
|
668
|
+
```bash
|
|
669
|
+
# Install
|
|
670
|
+
pip install {{project_name}}
|
|
671
|
+
|
|
672
|
+
# Basic usage
|
|
673
|
+
{{project_name}} --help
|
|
674
|
+
```
|
|
675
|
+
|
|
676
|
+
## Installation
|
|
677
|
+
|
|
678
|
+
### Requirements
|
|
679
|
+
|
|
680
|
+
- Python 3.13+
|
|
681
|
+
- {{project_name}} dependencies
|
|
682
|
+
|
|
683
|
+
### Install from PyPI
|
|
684
|
+
|
|
685
|
+
```bash
|
|
686
|
+
pip install {{project_name}}
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
### Development Installation
|
|
690
|
+
|
|
691
|
+
```bash
|
|
692
|
+
git clone {{repo_url}}.git
|
|
693
|
+
cd {{project_name}}
|
|
694
|
+
pip install -e .
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
## Usage
|
|
698
|
+
|
|
699
|
+
{% section usage_examples %}
|
|
700
|
+
|
|
701
|
+
## Documentation
|
|
702
|
+
|
|
703
|
+
- [User Guide](docs/user-guide.md)
|
|
704
|
+
- [API Reference](docs/api-reference.md)
|
|
705
|
+
- [Development Guide](docs/development.md)
|
|
706
|
+
|
|
707
|
+
## Contributing
|
|
708
|
+
|
|
709
|
+
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
710
|
+
|
|
711
|
+
## License
|
|
712
|
+
|
|
713
|
+
{{license}}
|
|
714
|
+
|
|
715
|
+
## Author
|
|
716
|
+
|
|
717
|
+
{{author}}
|
|
718
|
+
"""
|
|
719
|
+
|
|
720
|
+
def _get_changelog_template_content(self) -> str:
|
|
721
|
+
"""Get changelog template content."""
|
|
722
|
+
return """# Changelog
|
|
723
|
+
|
|
724
|
+
All notable changes to {{project_name}} will be documented in this file.
|
|
725
|
+
|
|
726
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
727
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
728
|
+
|
|
729
|
+
## [Unreleased]
|
|
730
|
+
|
|
731
|
+
{% section unreleased_changes %}
|
|
732
|
+
|
|
733
|
+
## [{{version}}] - {{generated_at}}
|
|
734
|
+
|
|
735
|
+
### Added
|
|
736
|
+
{% section added_features %}
|
|
737
|
+
|
|
738
|
+
### Changed
|
|
739
|
+
{% section changed_features %}
|
|
740
|
+
|
|
741
|
+
### Deprecated
|
|
742
|
+
{% section deprecated_features %}
|
|
743
|
+
|
|
744
|
+
### Removed
|
|
745
|
+
{% section removed_features %}
|
|
746
|
+
|
|
747
|
+
### Fixed
|
|
748
|
+
{% section fixed_issues %}
|
|
749
|
+
|
|
750
|
+
### Security
|
|
751
|
+
{% section security_updates %}
|
|
752
|
+
|
|
753
|
+
---
|
|
754
|
+
|
|
755
|
+
For a complete history, see [GitHub Releases]({{repo_url}}/releases).
|
|
756
|
+
"""
|