Spaces:
Running
Running
File size: 4,730 Bytes
24214fc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
#!/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) |