attune-ai 2.0.0__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.
- attune/__init__.py +358 -0
- attune/adaptive/__init__.py +13 -0
- attune/adaptive/task_complexity.py +127 -0
- attune/agent_monitoring.py +414 -0
- attune/cache/__init__.py +117 -0
- attune/cache/base.py +166 -0
- attune/cache/dependency_manager.py +256 -0
- attune/cache/hash_only.py +251 -0
- attune/cache/hybrid.py +457 -0
- attune/cache/storage.py +285 -0
- attune/cache_monitor.py +356 -0
- attune/cache_stats.py +298 -0
- attune/cli/__init__.py +152 -0
- attune/cli/__main__.py +12 -0
- attune/cli/commands/__init__.py +1 -0
- attune/cli/commands/batch.py +264 -0
- attune/cli/commands/cache.py +248 -0
- attune/cli/commands/help.py +331 -0
- attune/cli/commands/info.py +140 -0
- attune/cli/commands/inspect.py +436 -0
- attune/cli/commands/inspection.py +57 -0
- attune/cli/commands/memory.py +48 -0
- attune/cli/commands/metrics.py +92 -0
- attune/cli/commands/orchestrate.py +184 -0
- attune/cli/commands/patterns.py +207 -0
- attune/cli/commands/profiling.py +202 -0
- attune/cli/commands/provider.py +98 -0
- attune/cli/commands/routing.py +285 -0
- attune/cli/commands/setup.py +96 -0
- attune/cli/commands/status.py +235 -0
- attune/cli/commands/sync.py +166 -0
- attune/cli/commands/tier.py +121 -0
- attune/cli/commands/utilities.py +114 -0
- attune/cli/commands/workflow.py +579 -0
- attune/cli/core.py +32 -0
- attune/cli/parsers/__init__.py +68 -0
- attune/cli/parsers/batch.py +118 -0
- attune/cli/parsers/cache.py +65 -0
- attune/cli/parsers/help.py +41 -0
- attune/cli/parsers/info.py +26 -0
- attune/cli/parsers/inspect.py +66 -0
- attune/cli/parsers/metrics.py +42 -0
- attune/cli/parsers/orchestrate.py +61 -0
- attune/cli/parsers/patterns.py +54 -0
- attune/cli/parsers/provider.py +40 -0
- attune/cli/parsers/routing.py +110 -0
- attune/cli/parsers/setup.py +42 -0
- attune/cli/parsers/status.py +47 -0
- attune/cli/parsers/sync.py +31 -0
- attune/cli/parsers/tier.py +33 -0
- attune/cli/parsers/workflow.py +77 -0
- attune/cli/utils/__init__.py +1 -0
- attune/cli/utils/data.py +242 -0
- attune/cli/utils/helpers.py +68 -0
- attune/cli_legacy.py +3957 -0
- attune/cli_minimal.py +1159 -0
- attune/cli_router.py +437 -0
- attune/cli_unified.py +814 -0
- attune/config/__init__.py +66 -0
- attune/config/xml_config.py +286 -0
- attune/config.py +545 -0
- attune/coordination.py +870 -0
- attune/core.py +1511 -0
- attune/core_modules/__init__.py +15 -0
- attune/cost_tracker.py +626 -0
- attune/dashboard/__init__.py +41 -0
- attune/dashboard/app.py +512 -0
- attune/dashboard/simple_server.py +435 -0
- attune/dashboard/standalone_server.py +547 -0
- attune/discovery.py +306 -0
- attune/emergence.py +306 -0
- attune/exceptions.py +123 -0
- attune/feedback_loops.py +373 -0
- attune/hot_reload/README.md +473 -0
- attune/hot_reload/__init__.py +62 -0
- attune/hot_reload/config.py +83 -0
- attune/hot_reload/integration.py +229 -0
- attune/hot_reload/reloader.py +298 -0
- attune/hot_reload/watcher.py +183 -0
- attune/hot_reload/websocket.py +177 -0
- attune/levels.py +577 -0
- attune/leverage_points.py +441 -0
- attune/logging_config.py +261 -0
- attune/mcp/__init__.py +10 -0
- attune/mcp/server.py +506 -0
- attune/memory/__init__.py +237 -0
- attune/memory/claude_memory.py +469 -0
- attune/memory/config.py +224 -0
- attune/memory/control_panel.py +1290 -0
- attune/memory/control_panel_support.py +145 -0
- attune/memory/cross_session.py +845 -0
- attune/memory/edges.py +179 -0
- attune/memory/encryption.py +159 -0
- attune/memory/file_session.py +770 -0
- attune/memory/graph.py +570 -0
- attune/memory/long_term.py +913 -0
- attune/memory/long_term_types.py +99 -0
- attune/memory/mixins/__init__.py +25 -0
- attune/memory/mixins/backend_init_mixin.py +249 -0
- attune/memory/mixins/capabilities_mixin.py +208 -0
- attune/memory/mixins/handoff_mixin.py +208 -0
- attune/memory/mixins/lifecycle_mixin.py +49 -0
- attune/memory/mixins/long_term_mixin.py +352 -0
- attune/memory/mixins/promotion_mixin.py +109 -0
- attune/memory/mixins/short_term_mixin.py +182 -0
- attune/memory/nodes.py +179 -0
- attune/memory/redis_bootstrap.py +540 -0
- attune/memory/security/__init__.py +31 -0
- attune/memory/security/audit_logger.py +932 -0
- attune/memory/security/pii_scrubber.py +640 -0
- attune/memory/security/secrets_detector.py +678 -0
- attune/memory/short_term.py +2192 -0
- attune/memory/simple_storage.py +302 -0
- attune/memory/storage/__init__.py +15 -0
- attune/memory/storage_backend.py +167 -0
- attune/memory/summary_index.py +583 -0
- attune/memory/types.py +446 -0
- attune/memory/unified.py +182 -0
- attune/meta_workflows/__init__.py +74 -0
- attune/meta_workflows/agent_creator.py +248 -0
- attune/meta_workflows/builtin_templates.py +567 -0
- attune/meta_workflows/cli_commands/__init__.py +56 -0
- attune/meta_workflows/cli_commands/agent_commands.py +321 -0
- attune/meta_workflows/cli_commands/analytics_commands.py +442 -0
- attune/meta_workflows/cli_commands/config_commands.py +232 -0
- attune/meta_workflows/cli_commands/memory_commands.py +182 -0
- attune/meta_workflows/cli_commands/template_commands.py +354 -0
- attune/meta_workflows/cli_commands/workflow_commands.py +382 -0
- attune/meta_workflows/cli_meta_workflows.py +59 -0
- attune/meta_workflows/form_engine.py +292 -0
- attune/meta_workflows/intent_detector.py +409 -0
- attune/meta_workflows/models.py +569 -0
- attune/meta_workflows/pattern_learner.py +738 -0
- attune/meta_workflows/plan_generator.py +384 -0
- attune/meta_workflows/session_context.py +397 -0
- attune/meta_workflows/template_registry.py +229 -0
- attune/meta_workflows/workflow.py +984 -0
- attune/metrics/__init__.py +12 -0
- attune/metrics/collector.py +31 -0
- attune/metrics/prompt_metrics.py +194 -0
- attune/models/__init__.py +172 -0
- attune/models/__main__.py +13 -0
- attune/models/adaptive_routing.py +437 -0
- attune/models/auth_cli.py +444 -0
- attune/models/auth_strategy.py +450 -0
- attune/models/cli.py +655 -0
- attune/models/empathy_executor.py +354 -0
- attune/models/executor.py +257 -0
- attune/models/fallback.py +762 -0
- attune/models/provider_config.py +282 -0
- attune/models/registry.py +472 -0
- attune/models/tasks.py +359 -0
- attune/models/telemetry/__init__.py +71 -0
- attune/models/telemetry/analytics.py +594 -0
- attune/models/telemetry/backend.py +196 -0
- attune/models/telemetry/data_models.py +431 -0
- attune/models/telemetry/storage.py +489 -0
- attune/models/token_estimator.py +420 -0
- attune/models/validation.py +280 -0
- attune/monitoring/__init__.py +52 -0
- attune/monitoring/alerts.py +946 -0
- attune/monitoring/alerts_cli.py +448 -0
- attune/monitoring/multi_backend.py +271 -0
- attune/monitoring/otel_backend.py +362 -0
- attune/optimization/__init__.py +19 -0
- attune/optimization/context_optimizer.py +272 -0
- attune/orchestration/__init__.py +67 -0
- attune/orchestration/agent_templates.py +707 -0
- attune/orchestration/config_store.py +499 -0
- attune/orchestration/execution_strategies.py +2111 -0
- attune/orchestration/meta_orchestrator.py +1168 -0
- attune/orchestration/pattern_learner.py +696 -0
- attune/orchestration/real_tools.py +931 -0
- attune/pattern_cache.py +187 -0
- attune/pattern_library.py +542 -0
- attune/patterns/debugging/all_patterns.json +81 -0
- attune/patterns/debugging/workflow_20260107_1770825e.json +77 -0
- attune/patterns/refactoring_memory.json +89 -0
- attune/persistence.py +564 -0
- attune/platform_utils.py +265 -0
- attune/plugins/__init__.py +28 -0
- attune/plugins/base.py +361 -0
- attune/plugins/registry.py +268 -0
- attune/project_index/__init__.py +32 -0
- attune/project_index/cli.py +335 -0
- attune/project_index/index.py +667 -0
- attune/project_index/models.py +504 -0
- attune/project_index/reports.py +474 -0
- attune/project_index/scanner.py +777 -0
- attune/project_index/scanner_parallel.py +291 -0
- attune/prompts/__init__.py +61 -0
- attune/prompts/config.py +77 -0
- attune/prompts/context.py +177 -0
- attune/prompts/parser.py +285 -0
- attune/prompts/registry.py +313 -0
- attune/prompts/templates.py +208 -0
- attune/redis_config.py +302 -0
- attune/redis_memory.py +799 -0
- attune/resilience/__init__.py +56 -0
- attune/resilience/circuit_breaker.py +256 -0
- attune/resilience/fallback.py +179 -0
- attune/resilience/health.py +300 -0
- attune/resilience/retry.py +209 -0
- attune/resilience/timeout.py +135 -0
- attune/routing/__init__.py +43 -0
- attune/routing/chain_executor.py +433 -0
- attune/routing/classifier.py +217 -0
- attune/routing/smart_router.py +234 -0
- attune/routing/workflow_registry.py +343 -0
- attune/scaffolding/README.md +589 -0
- attune/scaffolding/__init__.py +35 -0
- attune/scaffolding/__main__.py +14 -0
- attune/scaffolding/cli.py +240 -0
- attune/scaffolding/templates/base_wizard.py.jinja2 +121 -0
- attune/scaffolding/templates/coach_wizard.py.jinja2 +321 -0
- attune/scaffolding/templates/domain_wizard.py.jinja2 +408 -0
- attune/scaffolding/templates/linear_flow_wizard.py.jinja2 +203 -0
- attune/socratic/__init__.py +256 -0
- attune/socratic/ab_testing.py +958 -0
- attune/socratic/blueprint.py +533 -0
- attune/socratic/cli.py +703 -0
- attune/socratic/collaboration.py +1114 -0
- attune/socratic/domain_templates.py +924 -0
- attune/socratic/embeddings.py +738 -0
- attune/socratic/engine.py +794 -0
- attune/socratic/explainer.py +682 -0
- attune/socratic/feedback.py +772 -0
- attune/socratic/forms.py +629 -0
- attune/socratic/generator.py +732 -0
- attune/socratic/llm_analyzer.py +637 -0
- attune/socratic/mcp_server.py +702 -0
- attune/socratic/session.py +312 -0
- attune/socratic/storage.py +667 -0
- attune/socratic/success.py +730 -0
- attune/socratic/visual_editor.py +860 -0
- attune/socratic/web_ui.py +958 -0
- attune/telemetry/__init__.py +39 -0
- attune/telemetry/agent_coordination.py +475 -0
- attune/telemetry/agent_tracking.py +367 -0
- attune/telemetry/approval_gates.py +545 -0
- attune/telemetry/cli.py +1231 -0
- attune/telemetry/commands/__init__.py +14 -0
- attune/telemetry/commands/dashboard_commands.py +696 -0
- attune/telemetry/event_streaming.py +409 -0
- attune/telemetry/feedback_loop.py +567 -0
- attune/telemetry/usage_tracker.py +591 -0
- attune/templates.py +754 -0
- attune/test_generator/__init__.py +38 -0
- attune/test_generator/__main__.py +14 -0
- attune/test_generator/cli.py +234 -0
- attune/test_generator/generator.py +355 -0
- attune/test_generator/risk_analyzer.py +216 -0
- attune/test_generator/templates/unit_test.py.jinja2 +272 -0
- attune/tier_recommender.py +384 -0
- attune/tools.py +183 -0
- attune/trust/__init__.py +28 -0
- attune/trust/circuit_breaker.py +579 -0
- attune/trust_building.py +527 -0
- attune/validation/__init__.py +19 -0
- attune/validation/xml_validator.py +281 -0
- attune/vscode_bridge.py +173 -0
- attune/workflow_commands.py +780 -0
- attune/workflow_patterns/__init__.py +33 -0
- attune/workflow_patterns/behavior.py +249 -0
- attune/workflow_patterns/core.py +76 -0
- attune/workflow_patterns/output.py +99 -0
- attune/workflow_patterns/registry.py +255 -0
- attune/workflow_patterns/structural.py +288 -0
- attune/workflows/__init__.py +539 -0
- attune/workflows/autonomous_test_gen.py +1268 -0
- attune/workflows/base.py +2667 -0
- attune/workflows/batch_processing.py +342 -0
- attune/workflows/bug_predict.py +1084 -0
- attune/workflows/builder.py +273 -0
- attune/workflows/caching.py +253 -0
- attune/workflows/code_review.py +1048 -0
- attune/workflows/code_review_adapters.py +312 -0
- attune/workflows/code_review_pipeline.py +722 -0
- attune/workflows/config.py +645 -0
- attune/workflows/dependency_check.py +644 -0
- attune/workflows/document_gen/__init__.py +25 -0
- attune/workflows/document_gen/config.py +30 -0
- attune/workflows/document_gen/report_formatter.py +162 -0
- attune/workflows/document_gen/workflow.py +1426 -0
- attune/workflows/document_manager.py +216 -0
- attune/workflows/document_manager_README.md +134 -0
- attune/workflows/documentation_orchestrator.py +1205 -0
- attune/workflows/history.py +510 -0
- attune/workflows/keyboard_shortcuts/__init__.py +39 -0
- attune/workflows/keyboard_shortcuts/generators.py +391 -0
- attune/workflows/keyboard_shortcuts/parsers.py +416 -0
- attune/workflows/keyboard_shortcuts/prompts.py +295 -0
- attune/workflows/keyboard_shortcuts/schema.py +193 -0
- attune/workflows/keyboard_shortcuts/workflow.py +509 -0
- attune/workflows/llm_base.py +363 -0
- attune/workflows/manage_docs.py +87 -0
- attune/workflows/manage_docs_README.md +134 -0
- attune/workflows/manage_documentation.py +821 -0
- attune/workflows/new_sample_workflow1.py +149 -0
- attune/workflows/new_sample_workflow1_README.md +150 -0
- attune/workflows/orchestrated_health_check.py +849 -0
- attune/workflows/orchestrated_release_prep.py +600 -0
- attune/workflows/output.py +413 -0
- attune/workflows/perf_audit.py +863 -0
- attune/workflows/pr_review.py +762 -0
- attune/workflows/progress.py +785 -0
- attune/workflows/progress_server.py +322 -0
- attune/workflows/progressive/README 2.md +454 -0
- attune/workflows/progressive/README.md +454 -0
- attune/workflows/progressive/__init__.py +82 -0
- attune/workflows/progressive/cli.py +219 -0
- attune/workflows/progressive/core.py +488 -0
- attune/workflows/progressive/orchestrator.py +723 -0
- attune/workflows/progressive/reports.py +520 -0
- attune/workflows/progressive/telemetry.py +274 -0
- attune/workflows/progressive/test_gen.py +495 -0
- attune/workflows/progressive/workflow.py +589 -0
- attune/workflows/refactor_plan.py +694 -0
- attune/workflows/release_prep.py +895 -0
- attune/workflows/release_prep_crew.py +969 -0
- attune/workflows/research_synthesis.py +404 -0
- attune/workflows/routing.py +168 -0
- attune/workflows/secure_release.py +593 -0
- attune/workflows/security_adapters.py +297 -0
- attune/workflows/security_audit.py +1329 -0
- attune/workflows/security_audit_phase3.py +355 -0
- attune/workflows/seo_optimization.py +633 -0
- attune/workflows/step_config.py +234 -0
- attune/workflows/telemetry_mixin.py +269 -0
- attune/workflows/test5.py +125 -0
- attune/workflows/test5_README.md +158 -0
- attune/workflows/test_coverage_boost_crew.py +849 -0
- attune/workflows/test_gen/__init__.py +52 -0
- attune/workflows/test_gen/ast_analyzer.py +249 -0
- attune/workflows/test_gen/config.py +88 -0
- attune/workflows/test_gen/data_models.py +38 -0
- attune/workflows/test_gen/report_formatter.py +289 -0
- attune/workflows/test_gen/test_templates.py +381 -0
- attune/workflows/test_gen/workflow.py +655 -0
- attune/workflows/test_gen.py +54 -0
- attune/workflows/test_gen_behavioral.py +477 -0
- attune/workflows/test_gen_parallel.py +341 -0
- attune/workflows/test_lifecycle.py +526 -0
- attune/workflows/test_maintenance.py +627 -0
- attune/workflows/test_maintenance_cli.py +590 -0
- attune/workflows/test_maintenance_crew.py +840 -0
- attune/workflows/test_runner.py +622 -0
- attune/workflows/tier_tracking.py +531 -0
- attune/workflows/xml_enhanced_crew.py +285 -0
- attune_ai-2.0.0.dist-info/METADATA +1026 -0
- attune_ai-2.0.0.dist-info/RECORD +457 -0
- attune_ai-2.0.0.dist-info/WHEEL +5 -0
- attune_ai-2.0.0.dist-info/entry_points.txt +26 -0
- attune_ai-2.0.0.dist-info/licenses/LICENSE +201 -0
- attune_ai-2.0.0.dist-info/licenses/LICENSE_CHANGE_ANNOUNCEMENT.md +101 -0
- attune_ai-2.0.0.dist-info/top_level.txt +5 -0
- attune_healthcare/__init__.py +13 -0
- attune_healthcare/monitors/__init__.py +9 -0
- attune_healthcare/monitors/clinical_protocol_monitor.py +315 -0
- attune_healthcare/monitors/monitoring/__init__.py +44 -0
- attune_healthcare/monitors/monitoring/protocol_checker.py +300 -0
- attune_healthcare/monitors/monitoring/protocol_loader.py +214 -0
- attune_healthcare/monitors/monitoring/sensor_parsers.py +306 -0
- attune_healthcare/monitors/monitoring/trajectory_analyzer.py +389 -0
- attune_llm/README.md +553 -0
- attune_llm/__init__.py +28 -0
- attune_llm/agent_factory/__init__.py +53 -0
- attune_llm/agent_factory/adapters/__init__.py +85 -0
- attune_llm/agent_factory/adapters/autogen_adapter.py +312 -0
- attune_llm/agent_factory/adapters/crewai_adapter.py +483 -0
- attune_llm/agent_factory/adapters/haystack_adapter.py +298 -0
- attune_llm/agent_factory/adapters/langchain_adapter.py +362 -0
- attune_llm/agent_factory/adapters/langgraph_adapter.py +333 -0
- attune_llm/agent_factory/adapters/native.py +228 -0
- attune_llm/agent_factory/adapters/wizard_adapter.py +423 -0
- attune_llm/agent_factory/base.py +305 -0
- attune_llm/agent_factory/crews/__init__.py +67 -0
- attune_llm/agent_factory/crews/code_review.py +1113 -0
- attune_llm/agent_factory/crews/health_check.py +1262 -0
- attune_llm/agent_factory/crews/refactoring.py +1128 -0
- attune_llm/agent_factory/crews/security_audit.py +1018 -0
- attune_llm/agent_factory/decorators.py +287 -0
- attune_llm/agent_factory/factory.py +558 -0
- attune_llm/agent_factory/framework.py +193 -0
- attune_llm/agent_factory/memory_integration.py +328 -0
- attune_llm/agent_factory/resilient.py +320 -0
- attune_llm/agents_md/__init__.py +22 -0
- attune_llm/agents_md/loader.py +218 -0
- attune_llm/agents_md/parser.py +271 -0
- attune_llm/agents_md/registry.py +307 -0
- attune_llm/claude_memory.py +466 -0
- attune_llm/cli/__init__.py +8 -0
- attune_llm/cli/sync_claude.py +487 -0
- attune_llm/code_health.py +1313 -0
- attune_llm/commands/__init__.py +51 -0
- attune_llm/commands/context.py +375 -0
- attune_llm/commands/loader.py +301 -0
- attune_llm/commands/models.py +231 -0
- attune_llm/commands/parser.py +371 -0
- attune_llm/commands/registry.py +429 -0
- attune_llm/config/__init__.py +29 -0
- attune_llm/config/unified.py +291 -0
- attune_llm/context/__init__.py +22 -0
- attune_llm/context/compaction.py +455 -0
- attune_llm/context/manager.py +434 -0
- attune_llm/contextual_patterns.py +361 -0
- attune_llm/core.py +907 -0
- attune_llm/git_pattern_extractor.py +435 -0
- attune_llm/hooks/__init__.py +24 -0
- attune_llm/hooks/config.py +306 -0
- attune_llm/hooks/executor.py +289 -0
- attune_llm/hooks/registry.py +302 -0
- attune_llm/hooks/scripts/__init__.py +39 -0
- attune_llm/hooks/scripts/evaluate_session.py +201 -0
- attune_llm/hooks/scripts/first_time_init.py +285 -0
- attune_llm/hooks/scripts/pre_compact.py +207 -0
- attune_llm/hooks/scripts/session_end.py +183 -0
- attune_llm/hooks/scripts/session_start.py +163 -0
- attune_llm/hooks/scripts/suggest_compact.py +225 -0
- attune_llm/learning/__init__.py +30 -0
- attune_llm/learning/evaluator.py +438 -0
- attune_llm/learning/extractor.py +514 -0
- attune_llm/learning/storage.py +560 -0
- attune_llm/levels.py +227 -0
- attune_llm/pattern_confidence.py +414 -0
- attune_llm/pattern_resolver.py +272 -0
- attune_llm/pattern_summary.py +350 -0
- attune_llm/providers.py +967 -0
- attune_llm/routing/__init__.py +32 -0
- attune_llm/routing/model_router.py +362 -0
- attune_llm/security/IMPLEMENTATION_SUMMARY.md +413 -0
- attune_llm/security/PHASE2_COMPLETE.md +384 -0
- attune_llm/security/PHASE2_SECRETS_DETECTOR_COMPLETE.md +271 -0
- attune_llm/security/QUICK_REFERENCE.md +316 -0
- attune_llm/security/README.md +262 -0
- attune_llm/security/__init__.py +62 -0
- attune_llm/security/audit_logger.py +929 -0
- attune_llm/security/audit_logger_example.py +152 -0
- attune_llm/security/pii_scrubber.py +640 -0
- attune_llm/security/secrets_detector.py +678 -0
- attune_llm/security/secrets_detector_example.py +304 -0
- attune_llm/security/secure_memdocs.py +1192 -0
- attune_llm/security/secure_memdocs_example.py +278 -0
- attune_llm/session_status.py +745 -0
- attune_llm/state.py +246 -0
- attune_llm/utils/__init__.py +5 -0
- attune_llm/utils/tokens.py +349 -0
- attune_software/SOFTWARE_PLUGIN_README.md +57 -0
- attune_software/__init__.py +13 -0
- attune_software/cli/__init__.py +120 -0
- attune_software/cli/inspect.py +362 -0
- attune_software/cli.py +574 -0
- attune_software/plugin.py +188 -0
- workflow_scaffolding/__init__.py +11 -0
- workflow_scaffolding/__main__.py +12 -0
- workflow_scaffolding/cli.py +206 -0
- workflow_scaffolding/generator.py +265 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"""Software Development Plugin for Empathy Framework
|
|
2
|
+
|
|
3
|
+
This plugin provides 16+ Coach wizards for code analysis,
|
|
4
|
+
demonstrating Level 4 Anticipatory Empathy in software development.
|
|
5
|
+
|
|
6
|
+
Based on real-world experience developing AI systems where the framework
|
|
7
|
+
transformed productivity with higher quality code developed many times faster.
|
|
8
|
+
|
|
9
|
+
Copyright 2025 Smart AI Memory, LLC
|
|
10
|
+
Licensed under Fair Source 0.9
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
import logging
|
|
14
|
+
import os
|
|
15
|
+
|
|
16
|
+
# Import from core framework
|
|
17
|
+
import sys
|
|
18
|
+
|
|
19
|
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))
|
|
20
|
+
|
|
21
|
+
from attune.plugins import BasePlugin, BaseWizard, PluginMetadata
|
|
22
|
+
|
|
23
|
+
logger = logging.getLogger(__name__)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class SoftwarePlugin(BasePlugin):
|
|
27
|
+
"""Software Development Domain Plugin
|
|
28
|
+
|
|
29
|
+
Provides wizards for:
|
|
30
|
+
- Security analysis
|
|
31
|
+
- Performance optimization
|
|
32
|
+
- Architecture review
|
|
33
|
+
- Testing strategy
|
|
34
|
+
- Code quality assessment
|
|
35
|
+
- And more...
|
|
36
|
+
|
|
37
|
+
All wizards operate at Level 3 (Proactive) or Level 4 (Anticipatory)
|
|
38
|
+
empathy levels.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
def get_metadata(self) -> PluginMetadata:
|
|
42
|
+
"""Return plugin metadata"""
|
|
43
|
+
return PluginMetadata(
|
|
44
|
+
name="Empathy Framework - Software Development",
|
|
45
|
+
version="1.0.0",
|
|
46
|
+
domain="software",
|
|
47
|
+
description=(
|
|
48
|
+
"16+ Coach wizards for code analysis and anticipatory "
|
|
49
|
+
"software development. Alerts you to bottlenecks, security "
|
|
50
|
+
"vulnerabilities, and architectural issues before they "
|
|
51
|
+
"become critical."
|
|
52
|
+
),
|
|
53
|
+
author="Smart AI Memory, LLC",
|
|
54
|
+
license="Apache-2.0",
|
|
55
|
+
requires_core_version="1.0.0",
|
|
56
|
+
dependencies=[], # Add any domain-specific deps
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
def register_wizards(self) -> dict[str, type[BaseWizard]]:
|
|
60
|
+
"""Register all software development wizards.
|
|
61
|
+
|
|
62
|
+
In our experience building these wizards, we found that the framework
|
|
63
|
+
enables a fundamental shift: instead of reactive debugging, the system
|
|
64
|
+
alerts you to emerging issues that would surface weeks later.
|
|
65
|
+
"""
|
|
66
|
+
wizards = {}
|
|
67
|
+
|
|
68
|
+
# Import wizards with graceful degradation
|
|
69
|
+
# (some wizards may have optional dependencies)
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
from .wizards.security_wizard import SecurityWizard
|
|
73
|
+
|
|
74
|
+
wizards["security"] = SecurityWizard
|
|
75
|
+
except ImportError as e:
|
|
76
|
+
logger.warning(f"SecurityWizard not available: {e}")
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
from .wizards.performance_wizard import PerformanceWizard
|
|
80
|
+
|
|
81
|
+
wizards["performance"] = PerformanceWizard
|
|
82
|
+
except ImportError as e:
|
|
83
|
+
logger.warning(f"PerformanceWizard not available: {e}")
|
|
84
|
+
|
|
85
|
+
try:
|
|
86
|
+
from .wizards.testing_wizard import TestingWizard
|
|
87
|
+
|
|
88
|
+
wizards["testing"] = TestingWizard
|
|
89
|
+
except ImportError as e:
|
|
90
|
+
logger.warning(f"TestingWizard not available: {e}")
|
|
91
|
+
|
|
92
|
+
try:
|
|
93
|
+
from .wizards.architecture_wizard import ArchitectureWizard
|
|
94
|
+
|
|
95
|
+
wizards["architecture"] = ArchitectureWizard
|
|
96
|
+
except ImportError as e:
|
|
97
|
+
logger.warning(f"ArchitectureWizard not available: {e}")
|
|
98
|
+
|
|
99
|
+
# AI Development Wizards (Level 4 Anticipatory)
|
|
100
|
+
try:
|
|
101
|
+
from .wizards.prompt_engineering_wizard import PromptEngineeringWizard
|
|
102
|
+
|
|
103
|
+
wizards["prompt_engineering"] = PromptEngineeringWizard
|
|
104
|
+
except ImportError as e:
|
|
105
|
+
logger.warning(f"PromptEngineeringWizard not available: {e}")
|
|
106
|
+
|
|
107
|
+
try:
|
|
108
|
+
from .wizards.ai_context_wizard import AIContextWindowWizard
|
|
109
|
+
|
|
110
|
+
wizards["context_window"] = AIContextWindowWizard
|
|
111
|
+
except ImportError as e:
|
|
112
|
+
logger.warning(f"AIContextWindowWizard not available: {e}")
|
|
113
|
+
|
|
114
|
+
try:
|
|
115
|
+
from .wizards.ai_collaboration_wizard import AICollaborationWizard
|
|
116
|
+
|
|
117
|
+
wizards["collaboration_pattern"] = AICollaborationWizard
|
|
118
|
+
except ImportError as e:
|
|
119
|
+
logger.warning(f"AICollaborationWizard not available: {e}")
|
|
120
|
+
|
|
121
|
+
try:
|
|
122
|
+
from .wizards.ai_documentation_wizard import AIDocumentationWizard
|
|
123
|
+
|
|
124
|
+
wizards["ai_documentation"] = AIDocumentationWizard
|
|
125
|
+
except ImportError as e:
|
|
126
|
+
logger.warning(f"AIDocumentationWizard not available: {e}")
|
|
127
|
+
|
|
128
|
+
try:
|
|
129
|
+
from .wizards.agent_orchestration_wizard import AgentOrchestrationWizard
|
|
130
|
+
|
|
131
|
+
wizards["agent_orchestration"] = AgentOrchestrationWizard
|
|
132
|
+
except ImportError as e:
|
|
133
|
+
logger.warning(f"AgentOrchestrationWizard not available: {e}")
|
|
134
|
+
|
|
135
|
+
try:
|
|
136
|
+
from .wizards.rag_pattern_wizard import RAGPatternWizard
|
|
137
|
+
|
|
138
|
+
wizards["rag_pattern"] = RAGPatternWizard
|
|
139
|
+
except ImportError as e:
|
|
140
|
+
logger.warning(f"RAGPatternWizard not available: {e}")
|
|
141
|
+
|
|
142
|
+
try:
|
|
143
|
+
from .wizards.multi_model_wizard import MultiModelWizard
|
|
144
|
+
|
|
145
|
+
wizards["multi_model"] = MultiModelWizard
|
|
146
|
+
except ImportError as e:
|
|
147
|
+
logger.warning(f"MultiModelWizard not available: {e}")
|
|
148
|
+
|
|
149
|
+
# Add remaining wizards...
|
|
150
|
+
# In production, you'd import all 16+ wizards
|
|
151
|
+
|
|
152
|
+
logger.info(f"Software plugin registered {len(wizards)} wizards")
|
|
153
|
+
|
|
154
|
+
return wizards
|
|
155
|
+
|
|
156
|
+
def register_patterns(self) -> dict:
|
|
157
|
+
"""Register software development patterns.
|
|
158
|
+
|
|
159
|
+
These patterns were learned from real-world usage and enable
|
|
160
|
+
cross-domain learning (Level 5 Systems Empathy).
|
|
161
|
+
"""
|
|
162
|
+
return {
|
|
163
|
+
"domain": "software",
|
|
164
|
+
"patterns": {
|
|
165
|
+
"testing_bottleneck": {
|
|
166
|
+
"description": (
|
|
167
|
+
"Manual testing burden grows faster than team size. "
|
|
168
|
+
"Alert: When test count > 25 or test time > 15min, "
|
|
169
|
+
"recommend automation framework."
|
|
170
|
+
),
|
|
171
|
+
"indicators": ["test_count_growth_rate", "manual_test_time", "wizard_count"],
|
|
172
|
+
"threshold": "test_time > 900 seconds",
|
|
173
|
+
"recommendation": "Implement test automation framework",
|
|
174
|
+
},
|
|
175
|
+
"security_drift": {
|
|
176
|
+
"description": (
|
|
177
|
+
"Security practices degrade over time without active "
|
|
178
|
+
"monitoring. Alert: When new code bypasses security "
|
|
179
|
+
"patterns established in existing code."
|
|
180
|
+
),
|
|
181
|
+
"indicators": [
|
|
182
|
+
"input_validation_coverage",
|
|
183
|
+
"authentication_consistency",
|
|
184
|
+
"data_sanitization_patterns",
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"""CLI for workflow scaffolding.
|
|
2
|
+
|
|
3
|
+
Provides command-line interface for creating workflows.
|
|
4
|
+
|
|
5
|
+
Copyright 2025 Smart-AI-Memory
|
|
6
|
+
Licensed under Fair Source License 0.9
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import sys
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from rich.console import Console
|
|
13
|
+
from rich.table import Table
|
|
14
|
+
|
|
15
|
+
from attune.workflow_patterns import get_workflow_pattern_registry
|
|
16
|
+
|
|
17
|
+
from .generator import WorkflowGenerator
|
|
18
|
+
|
|
19
|
+
console = Console()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def cmd_create(args):
|
|
23
|
+
"""Create a new workflow."""
|
|
24
|
+
workflow_name = args.name
|
|
25
|
+
description = args.description or f"{workflow_name} workflow"
|
|
26
|
+
patterns = args.patterns.split(",") if args.patterns else []
|
|
27
|
+
|
|
28
|
+
# Auto-select patterns if none provided
|
|
29
|
+
if not patterns:
|
|
30
|
+
console.print("[yellow]No patterns specified, using defaults for simple workflow[/yellow]")
|
|
31
|
+
patterns = ["single-stage"]
|
|
32
|
+
|
|
33
|
+
# Create generator
|
|
34
|
+
generator = WorkflowGenerator()
|
|
35
|
+
registry = get_workflow_pattern_registry()
|
|
36
|
+
|
|
37
|
+
# Validate patterns
|
|
38
|
+
valid, error = registry.validate_pattern_combination(patterns)
|
|
39
|
+
if not valid:
|
|
40
|
+
console.print(f"[red]Error: {error}[/red]")
|
|
41
|
+
sys.exit(1)
|
|
42
|
+
|
|
43
|
+
console.print(f"[bold]Creating workflow:[/bold] {workflow_name}")
|
|
44
|
+
console.print(f"[bold]Description:[/bold] {description}")
|
|
45
|
+
console.print(f"[bold]Patterns:[/bold] {', '.join(patterns)}")
|
|
46
|
+
|
|
47
|
+
# Generate and write
|
|
48
|
+
output_dir = Path(args.output) if args.output else Path.cwd()
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
written = generator.write_workflow(
|
|
52
|
+
output_dir=output_dir,
|
|
53
|
+
workflow_name=workflow_name,
|
|
54
|
+
description=description,
|
|
55
|
+
patterns=patterns,
|
|
56
|
+
stages=args.stages.split(",") if args.stages else None,
|
|
57
|
+
tier_map=_parse_tier_map(args.tier_map) if args.tier_map else None,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
console.print("\n[green]✓[/green] Workflow created successfully!\n")
|
|
61
|
+
console.print("[bold]Generated files:[/bold]")
|
|
62
|
+
for file_type, path in written.items():
|
|
63
|
+
console.print(f" - {file_type}: {path}")
|
|
64
|
+
|
|
65
|
+
console.print("\n[bold]Next steps:[/bold]")
|
|
66
|
+
console.print("1. Review generated files")
|
|
67
|
+
console.print("2. Implement stage logic (search for TODO comments)")
|
|
68
|
+
console.print(f"3. Run tests: pytest {written['test']}")
|
|
69
|
+
console.print(f"4. Run workflow: empathy workflow run {workflow_name}")
|
|
70
|
+
|
|
71
|
+
except Exception as e:
|
|
72
|
+
console.print(f"[red]Error creating workflow: {e}[/red]")
|
|
73
|
+
sys.exit(1)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def cmd_list_patterns(args):
|
|
77
|
+
"""List available patterns."""
|
|
78
|
+
registry = get_workflow_pattern_registry()
|
|
79
|
+
patterns = registry.list_all()
|
|
80
|
+
|
|
81
|
+
# Create table
|
|
82
|
+
table = Table(title="Workflow Patterns")
|
|
83
|
+
table.add_column("ID", style="cyan")
|
|
84
|
+
table.add_column("Name", style="green")
|
|
85
|
+
table.add_column("Category", style="yellow")
|
|
86
|
+
table.add_column("Complexity", style="magenta")
|
|
87
|
+
table.add_column("Risk", justify="right")
|
|
88
|
+
|
|
89
|
+
for pattern in sorted(patterns, key=lambda p: p.id):
|
|
90
|
+
table.add_row(
|
|
91
|
+
pattern.id,
|
|
92
|
+
pattern.name,
|
|
93
|
+
pattern.category.value,
|
|
94
|
+
pattern.complexity.value,
|
|
95
|
+
f"{pattern.risk_weight:.1f}",
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
console.print(table)
|
|
99
|
+
|
|
100
|
+
# Show usage examples
|
|
101
|
+
console.print("\n[bold]Common Combinations:[/bold]")
|
|
102
|
+
console.print(" Simple workflow: single-stage")
|
|
103
|
+
console.print(" Code analysis: multi-stage,code-scanner,conditional-tier")
|
|
104
|
+
console.print(" Multi-agent: crew-based,result-dataclass")
|
|
105
|
+
console.print(" Configurable: multi-stage,config-driven")
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def cmd_recommend(args):
|
|
109
|
+
"""Recommend patterns for a workflow type."""
|
|
110
|
+
registry = get_workflow_pattern_registry()
|
|
111
|
+
workflow_type = args.type
|
|
112
|
+
|
|
113
|
+
recommendations = registry.recommend_for_workflow(workflow_type)
|
|
114
|
+
|
|
115
|
+
if not recommendations:
|
|
116
|
+
console.print(f"[yellow]No recommendations found for type: {workflow_type}[/yellow]")
|
|
117
|
+
console.print(
|
|
118
|
+
"\nAvailable types: code-analysis, simple, multi-agent, configurable, cost-optimized"
|
|
119
|
+
)
|
|
120
|
+
return
|
|
121
|
+
|
|
122
|
+
console.print(f"[bold]Recommendations for '{workflow_type}':[/bold]\n")
|
|
123
|
+
|
|
124
|
+
for pattern in recommendations:
|
|
125
|
+
console.print(f"[cyan]{pattern.id}[/cyan] - {pattern.name}")
|
|
126
|
+
console.print(f" {pattern.description}")
|
|
127
|
+
if pattern.use_cases:
|
|
128
|
+
console.print(f" Use for: {', '.join(pattern.use_cases)}")
|
|
129
|
+
console.print()
|
|
130
|
+
|
|
131
|
+
pattern_ids = [p.id for p in recommendations]
|
|
132
|
+
console.print("[bold]Create command:[/bold]")
|
|
133
|
+
console.print(
|
|
134
|
+
f"python -m workflow_scaffolding create my-workflow --patterns {','.join(pattern_ids)}"
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _parse_tier_map(tier_map_str: str) -> dict[str, str]:
|
|
139
|
+
"""Parse tier map from string.
|
|
140
|
+
|
|
141
|
+
Args:
|
|
142
|
+
tier_map_str: Format "stage1:CHEAP,stage2:CAPABLE"
|
|
143
|
+
|
|
144
|
+
Returns:
|
|
145
|
+
Dict mapping stage to tier
|
|
146
|
+
|
|
147
|
+
"""
|
|
148
|
+
tier_map = {}
|
|
149
|
+
for pair in tier_map_str.split(","):
|
|
150
|
+
stage, tier = pair.split(":")
|
|
151
|
+
tier_map[stage.strip()] = tier.strip()
|
|
152
|
+
return tier_map
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def main():
|
|
156
|
+
"""Main CLI entry point."""
|
|
157
|
+
import argparse
|
|
158
|
+
|
|
159
|
+
parser = argparse.ArgumentParser(
|
|
160
|
+
description="Workflow Factory - Create workflows 12x faster",
|
|
161
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
subparsers = parser.add_subparsers(dest="command", help="Command to run")
|
|
165
|
+
|
|
166
|
+
# create command
|
|
167
|
+
parser_create = subparsers.add_parser("create", help="Create a new workflow")
|
|
168
|
+
parser_create.add_argument("name", help="Workflow name (kebab-case, e.g., bug-scanner)")
|
|
169
|
+
parser_create.add_argument("--description", "-d", help="Workflow description")
|
|
170
|
+
parser_create.add_argument(
|
|
171
|
+
"--patterns",
|
|
172
|
+
"-p",
|
|
173
|
+
help="Comma-separated pattern IDs (e.g., multi-stage,conditional-tier)",
|
|
174
|
+
)
|
|
175
|
+
parser_create.add_argument("--stages", "-s", help="Comma-separated stage names")
|
|
176
|
+
parser_create.add_argument(
|
|
177
|
+
"--tier-map",
|
|
178
|
+
"-t",
|
|
179
|
+
help="Tier map (e.g., analyze:CHEAP,process:CAPABLE)",
|
|
180
|
+
)
|
|
181
|
+
parser_create.add_argument("--output", "-o", help="Output directory (default: current)")
|
|
182
|
+
parser_create.set_defaults(func=cmd_create)
|
|
183
|
+
|
|
184
|
+
# list-patterns command
|
|
185
|
+
parser_list = subparsers.add_parser("list-patterns", help="List available patterns")
|
|
186
|
+
parser_list.set_defaults(func=cmd_list_patterns)
|
|
187
|
+
|
|
188
|
+
# recommend command
|
|
189
|
+
parser_recommend = subparsers.add_parser("recommend", help="Recommend patterns for a type")
|
|
190
|
+
parser_recommend.add_argument(
|
|
191
|
+
"type",
|
|
192
|
+
help="Workflow type (code-analysis, simple, multi-agent, etc.)",
|
|
193
|
+
)
|
|
194
|
+
parser_recommend.set_defaults(func=cmd_recommend)
|
|
195
|
+
|
|
196
|
+
args = parser.parse_args()
|
|
197
|
+
|
|
198
|
+
if not args.command:
|
|
199
|
+
parser.print_help()
|
|
200
|
+
sys.exit(1)
|
|
201
|
+
|
|
202
|
+
args.func(args)
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
if __name__ == "__main__":
|
|
206
|
+
main()
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"""Workflow code generator.
|
|
2
|
+
|
|
3
|
+
Generates workflow code from patterns and templates.
|
|
4
|
+
|
|
5
|
+
Copyright 2025 Smart-AI-Memory
|
|
6
|
+
Licensed under Fair Source License 0.9
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from datetime import datetime
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
from jinja2 import Environment, FileSystemLoader
|
|
14
|
+
|
|
15
|
+
from attune.workflow_patterns import get_workflow_pattern_registry
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class WorkflowGenerator:
|
|
19
|
+
"""Generates workflow code from patterns."""
|
|
20
|
+
|
|
21
|
+
def __init__(self, templates_dir: Path | None = None):
|
|
22
|
+
"""Initialize generator.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
templates_dir: Path to templates directory
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
if templates_dir is None:
|
|
29
|
+
templates_dir = Path(__file__).parent / "templates"
|
|
30
|
+
|
|
31
|
+
self.templates_dir = templates_dir
|
|
32
|
+
self.env = Environment(
|
|
33
|
+
loader=FileSystemLoader(str(templates_dir)),
|
|
34
|
+
trim_blocks=True,
|
|
35
|
+
lstrip_blocks=True,
|
|
36
|
+
)
|
|
37
|
+
self.registry = get_workflow_pattern_registry()
|
|
38
|
+
|
|
39
|
+
def _workflow_name_to_class_name(self, workflow_name: str) -> str:
|
|
40
|
+
"""Convert workflow-name to WorkflowName class name.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
workflow_name: Workflow name (e.g., "bug-scanner")
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
Class name (e.g., "BugScannerWorkflow")
|
|
47
|
+
|
|
48
|
+
"""
|
|
49
|
+
parts = workflow_name.replace("-", "_").replace("_", " ").split()
|
|
50
|
+
return "".join(p.capitalize() for p in parts) + "Workflow"
|
|
51
|
+
|
|
52
|
+
def _workflow_name_to_file_name(self, workflow_name: str) -> str:
|
|
53
|
+
"""Convert workflow-name to file_name.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
workflow_name: Workflow name (e.g., "bug-scanner")
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
File name (e.g., "bug_scanner")
|
|
60
|
+
|
|
61
|
+
"""
|
|
62
|
+
return workflow_name.replace("-", "_")
|
|
63
|
+
|
|
64
|
+
def _merge_code_sections(self, sections_by_location: dict) -> dict[str, str]:
|
|
65
|
+
"""Merge code sections into single strings per location.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
sections_by_location: Dict mapping location to list of CodeSection
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
Dict mapping location to merged code string
|
|
72
|
+
|
|
73
|
+
"""
|
|
74
|
+
merged = {}
|
|
75
|
+
|
|
76
|
+
for location, sections in sections_by_location.items():
|
|
77
|
+
# Sort by priority (highest first)
|
|
78
|
+
sections = sorted(sections, key=lambda s: -s.priority)
|
|
79
|
+
|
|
80
|
+
# Merge code
|
|
81
|
+
code_parts = [s.code for s in sections]
|
|
82
|
+
merged[location] = "\n\n".join(code_parts)
|
|
83
|
+
|
|
84
|
+
return merged
|
|
85
|
+
|
|
86
|
+
def generate_workflow(
|
|
87
|
+
self,
|
|
88
|
+
workflow_name: str,
|
|
89
|
+
description: str,
|
|
90
|
+
patterns: list[str],
|
|
91
|
+
stages: list[str] | None = None,
|
|
92
|
+
tier_map: dict[str, str] | None = None,
|
|
93
|
+
**kwargs: Any,
|
|
94
|
+
) -> dict[str, str]:
|
|
95
|
+
"""Generate workflow code.
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
workflow_name: Workflow name (e.g., "bug-scanner")
|
|
99
|
+
description: Workflow description
|
|
100
|
+
patterns: List of pattern IDs to use
|
|
101
|
+
stages: List of stage names (auto-generated if None)
|
|
102
|
+
tier_map: Mapping of stage to tier (auto-generated if None)
|
|
103
|
+
**kwargs: Additional context for code generation
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
Dict with generated files:
|
|
107
|
+
- "workflow": Main workflow file content
|
|
108
|
+
- "test": Test file content
|
|
109
|
+
- "readme": README content
|
|
110
|
+
|
|
111
|
+
"""
|
|
112
|
+
# Validate patterns
|
|
113
|
+
valid, error = self.registry.validate_pattern_combination(patterns)
|
|
114
|
+
if not valid:
|
|
115
|
+
raise ValueError(f"Invalid pattern combination: {error}")
|
|
116
|
+
|
|
117
|
+
# Auto-generate stages if not provided
|
|
118
|
+
if stages is None:
|
|
119
|
+
if "single-stage" in patterns:
|
|
120
|
+
stages = ["process"]
|
|
121
|
+
elif "multi-stage" in patterns:
|
|
122
|
+
stages = ["analyze", "process", "report"]
|
|
123
|
+
elif "crew-based" in patterns:
|
|
124
|
+
stages = ["diagnose", "fix"]
|
|
125
|
+
else:
|
|
126
|
+
stages = ["execute"]
|
|
127
|
+
|
|
128
|
+
# Auto-generate tier map if not provided
|
|
129
|
+
if tier_map is None:
|
|
130
|
+
if len(stages) == 1:
|
|
131
|
+
tier_map = {stages[0]: "CAPABLE"}
|
|
132
|
+
elif len(stages) == 2:
|
|
133
|
+
tier_map = {stages[0]: "CHEAP", stages[1]: "CAPABLE"}
|
|
134
|
+
else:
|
|
135
|
+
tier_map = {
|
|
136
|
+
stages[0]: "CHEAP",
|
|
137
|
+
**dict.fromkeys(stages[1:-1], "CAPABLE"),
|
|
138
|
+
stages[-1]: "PREMIUM",
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
# Generate class and file names
|
|
142
|
+
class_name = self._workflow_name_to_class_name(workflow_name)
|
|
143
|
+
workflow_file = self._workflow_name_to_file_name(workflow_name)
|
|
144
|
+
|
|
145
|
+
# Build context
|
|
146
|
+
context = {
|
|
147
|
+
"workflow_name": workflow_name,
|
|
148
|
+
"class_name": class_name,
|
|
149
|
+
"workflow_file": workflow_file,
|
|
150
|
+
"description": description,
|
|
151
|
+
"stages": stages,
|
|
152
|
+
"tier_map": tier_map,
|
|
153
|
+
"generation_date": datetime.now().strftime("%Y-%m-%d"),
|
|
154
|
+
"complexity": self._determine_complexity(patterns),
|
|
155
|
+
"patterns": [self.registry.get(p) for p in patterns if self.registry.get(p)],
|
|
156
|
+
# Pattern flags
|
|
157
|
+
"has_conditional_tier": "conditional-tier" in patterns,
|
|
158
|
+
"has_config_driven": "config-driven" in patterns,
|
|
159
|
+
"has_crew_based": "crew-based" in patterns,
|
|
160
|
+
"has_result_dataclass": "result-dataclass" in patterns,
|
|
161
|
+
"has_code_scanner": "code-scanner" in patterns,
|
|
162
|
+
"has_imports": False,
|
|
163
|
+
"has_step_config": False,
|
|
164
|
+
**kwargs,
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
# Generate code sections from patterns
|
|
168
|
+
sections_by_location = self.registry.generate_code_sections(patterns, context)
|
|
169
|
+
merged_sections = self._merge_code_sections(sections_by_location)
|
|
170
|
+
|
|
171
|
+
# Update context with merged sections
|
|
172
|
+
context.update(
|
|
173
|
+
{
|
|
174
|
+
"imports": merged_sections.get("imports", ""),
|
|
175
|
+
"helper_functions": merged_sections.get("helper_functions", ""),
|
|
176
|
+
"dataclasses": merged_sections.get("dataclasses", ""),
|
|
177
|
+
"class_attributes": merged_sections.get("class_attributes", ""),
|
|
178
|
+
"init_method": merged_sections.get("init_method", ""),
|
|
179
|
+
"methods": merged_sections.get("methods", ""),
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
# Update flags
|
|
184
|
+
context["has_imports"] = bool(context["imports"])
|
|
185
|
+
context["has_step_config"] = "WorkflowStepConfig" in str(merged_sections)
|
|
186
|
+
|
|
187
|
+
# Generate files
|
|
188
|
+
workflow_template = self.env.get_template("workflow.py.j2")
|
|
189
|
+
test_template = self.env.get_template("test.py.j2")
|
|
190
|
+
readme_template = self.env.get_template("README.md.j2")
|
|
191
|
+
|
|
192
|
+
return {
|
|
193
|
+
"workflow": workflow_template.render(**context),
|
|
194
|
+
"test": test_template.render(**context),
|
|
195
|
+
"readme": readme_template.render(**context),
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
def _determine_complexity(self, patterns: list[str]) -> str:
|
|
199
|
+
"""Determine overall workflow complexity.
|
|
200
|
+
|
|
201
|
+
Args:
|
|
202
|
+
patterns: List of pattern IDs
|
|
203
|
+
|
|
204
|
+
Returns:
|
|
205
|
+
Complexity level string
|
|
206
|
+
|
|
207
|
+
"""
|
|
208
|
+
if "crew-based" in patterns or "multi-stage" in patterns:
|
|
209
|
+
return "COMPLEX"
|
|
210
|
+
if "conditional-tier" in patterns or "config-driven" in patterns:
|
|
211
|
+
return "MODERATE"
|
|
212
|
+
return "SIMPLE"
|
|
213
|
+
|
|
214
|
+
def write_workflow(
|
|
215
|
+
self,
|
|
216
|
+
output_dir: Path,
|
|
217
|
+
workflow_name: str,
|
|
218
|
+
description: str,
|
|
219
|
+
patterns: list[str],
|
|
220
|
+
**kwargs: Any,
|
|
221
|
+
) -> dict[str, Path]:
|
|
222
|
+
"""Generate and write workflow files.
|
|
223
|
+
|
|
224
|
+
Args:
|
|
225
|
+
output_dir: Base output directory
|
|
226
|
+
workflow_name: Workflow name
|
|
227
|
+
description: Workflow description
|
|
228
|
+
patterns: List of pattern IDs
|
|
229
|
+
**kwargs: Additional generation parameters
|
|
230
|
+
|
|
231
|
+
Returns:
|
|
232
|
+
Dict mapping file type to written path
|
|
233
|
+
|
|
234
|
+
"""
|
|
235
|
+
# Generate code
|
|
236
|
+
generated = self.generate_workflow(
|
|
237
|
+
workflow_name,
|
|
238
|
+
description,
|
|
239
|
+
patterns,
|
|
240
|
+
**kwargs,
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
# Determine file paths
|
|
244
|
+
workflow_file = self._workflow_name_to_file_name(workflow_name)
|
|
245
|
+
|
|
246
|
+
workflow_dir = output_dir / "src" / "attune" / "workflows"
|
|
247
|
+
test_dir = output_dir / "tests" / "unit" / "workflows"
|
|
248
|
+
|
|
249
|
+
workflow_dir.mkdir(parents=True, exist_ok=True)
|
|
250
|
+
test_dir.mkdir(parents=True, exist_ok=True)
|
|
251
|
+
|
|
252
|
+
workflow_path = workflow_dir / f"{workflow_file}.py"
|
|
253
|
+
test_path = test_dir / f"test_{workflow_file}.py"
|
|
254
|
+
readme_path = workflow_dir / f"{workflow_file}_README.md"
|
|
255
|
+
|
|
256
|
+
# Write files
|
|
257
|
+
workflow_path.write_text(generated["workflow"])
|
|
258
|
+
test_path.write_text(generated["test"])
|
|
259
|
+
readme_path.write_text(generated["readme"])
|
|
260
|
+
|
|
261
|
+
return {
|
|
262
|
+
"workflow": workflow_path,
|
|
263
|
+
"test": test_path,
|
|
264
|
+
"readme": readme_path,
|
|
265
|
+
}
|