Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Script to update spiritual_monitor.txt to use shared indicators and components. | |
| """ | |
| import sys | |
| import os | |
| sys.path.append('src') | |
| from config.prompt_management.prompt_integration import create_integrator | |
| from config.prompt_loader import PROMPTS_DIR | |
| def update_spiritual_monitor(): | |
| """Update spiritual_monitor.txt to use shared components.""" | |
| print("Updating spiritual_monitor.txt to use shared components...") | |
| # Create integrator | |
| integrator = create_integrator() | |
| # Validate current integration | |
| print("\n1. Validating current integration...") | |
| validation = integrator.validate_prompt_integration('spiritual_monitor') | |
| print(f" Current indicators: {validation['indicator_count']}") | |
| print(f" Current rules: {validation['rule_count']}") | |
| print(f" Current templates: {validation['template_count']}") | |
| if validation['validation_errors']: | |
| print(" Validation errors:") | |
| for error in validation['validation_errors']: | |
| print(f" - {error}") | |
| if validation['recommendations']: | |
| print(" Recommendations:") | |
| for rec in validation['recommendations']: | |
| print(f" - {rec}") | |
| # Read current prompt file | |
| print("\n2. Reading current prompt file...") | |
| filepath = PROMPTS_DIR / "spiritual_monitor.txt" | |
| if not filepath.exists(): | |
| print(f" Error: File not found: {filepath}") | |
| return False | |
| with open(filepath, 'r', encoding='utf-8') as f: | |
| original_content = f.read() | |
| print(f" Original file size: {len(original_content)} characters") | |
| # Generate enhanced prompt with shared components | |
| print("\n3. Generating enhanced prompt...") | |
| enhanced_prompt = integrator.get_enhanced_prompt('spiritual_monitor') | |
| print(f" Enhanced file size: {len(enhanced_prompt)} characters") | |
| # Show what will be added | |
| print("\n4. Preview of shared components integration:") | |
| # Generate indicators section preview | |
| indicators_section = integrator.generate_indicators_section() | |
| if indicators_section: | |
| lines = indicators_section.split('\n') | |
| print(f" Indicators section: {len(lines)} lines") | |
| print(f" Preview: {lines[0][:60]}...") | |
| # Generate rules section preview | |
| rules_section = integrator.generate_rules_section() | |
| if rules_section: | |
| lines = rules_section.split('\n') | |
| print(f" Rules section: {len(lines)} lines") | |
| print(f" Preview: {lines[0][:60]}...") | |
| # Ask for confirmation | |
| print("\n5. Ready to update the file.") | |
| print(" This will:") | |
| print(" - Create a backup of the original file") | |
| print(" - Update the file with shared components") | |
| print(" - Maintain all existing functionality") | |
| response = input("\nProceed with update? (y/N): ").strip().lower() | |
| if response != 'y': | |
| print("Update cancelled.") | |
| return False | |
| # Perform the update | |
| print("\n6. Updating file...") | |
| success = integrator.update_prompt_file('spiritual_monitor', backup=True) | |
| if success: | |
| print("β File updated successfully!") | |
| # Validate the update | |
| print("\n7. Validating updated integration...") | |
| new_validation = integrator.validate_prompt_integration('spiritual_monitor') | |
| print(f" Updated indicators: {new_validation['indicator_count']}") | |
| print(f" Updated rules: {new_validation['rule_count']}") | |
| print(f" Updated templates: {new_validation['template_count']}") | |
| if new_validation['validation_errors']: | |
| print(" Validation errors:") | |
| for error in new_validation['validation_errors']: | |
| print(f" - {error}") | |
| else: | |
| print(" β No validation errors found") | |
| # Test that the prompt can be loaded | |
| print("\n8. Testing prompt loading...") | |
| try: | |
| config = integrator.controller.get_prompt('spiritual_monitor') | |
| print(f" β Prompt loaded successfully") | |
| print(f" β Base prompt: {len(config.base_prompt)} characters") | |
| print(f" β Shared indicators: {len(config.shared_indicators)}") | |
| print(f" β Shared rules: {len(config.shared_rules)}") | |
| except Exception as e: | |
| print(f" β Error loading prompt: {e}") | |
| return False | |
| print("\nβ spiritual_monitor.txt update completed successfully!") | |
| return True | |
| else: | |
| print("β Failed to update file.") | |
| return False | |
| if __name__ == "__main__": | |
| success = update_spiritual_monitor() | |
| sys.exit(0 if success else 1) |