import sys import os from pathlib import Path import json from datetime import datetime # Add parent directory to path so we can import buddai modules sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from buddai_executive import BuddAI def test_personality_loading(): print("๐Ÿงช Testing Personality Loading...") # Initialize BuddAI (mocking server_mode to avoid input loops) try: ai = BuddAI(user_id="test_user", server_mode=True) # 1. Check Identity & Meta print("\n๐Ÿ‘ค Verifying Identity & Meta...") user_name = ai.get_personality_value("identity.user_name") ai_name = ai.get_personality_value("identity.ai_name") version = ai.get_personality_value("meta.version") if user_name == "James" and ai_name == "BuddAI": print(f"โœ… Identity Loaded: {ai_name} v{version} is ready to assist {user_name}") else: print(f"โŒ Identity Mismatch. Got User: {user_name}, AI: {ai_name}") # 2. Check Communication & Phrases print("\n๐Ÿ’ฌ Verifying Communication Style...") welcome = ai.get_personality_value("communication.welcome_message") phrases = ai.get_personality_value("identity.signature_phrases") if welcome and "{rule_count}" in welcome: print(f"โœ… Welcome Message Template Loaded") else: print(f"โŒ Welcome Message Issue: {welcome}") if phrases and len(phrases) > 0: print(f"โœ… Loaded {len(phrases)} signature phrases (e.g., '{phrases[0]}')") else: print("โŒ No signature phrases found") # 3. Test Schedule Logic & Work Cycles print("\nโฐ Testing Schedule & Work Cycles...") status = ai.get_user_status() current_time = datetime.now().strftime('%H:%M') print(f" Current Time: {current_time}") print(f" Detected Status: {status}") # Verify specific schedule slots exist morning_mode = ai.get_personality_value(["work_cycles", "schedule", "weekdays", "0-4", "5.5-6.5", "mode"]) if morning_mode == "morning_build_peak": print("โœ… Morning Build Peak schedule slot verified") else: print(f"โŒ Morning schedule slot missing or incorrect: {morning_mode}") # 4. Verify Forge Theory Configuration print("\nโšก Verifying Forge Theory...") forge_enabled = ai.get_personality_value("forge_theory.enabled") k_balanced = ai.get_personality_value("forge_theory.constants.balanced.value") formula = ai.get_personality_value("forge_theory.formula") if forge_enabled and k_balanced == 0.1: print(f"โœ… Forge Theory Active (Balanced k={k_balanced})") print(f" Formula: {formula}") else: print(f"โŒ Forge Theory configuration mismatch") # 5. Verify Technical Preferences print("\n๐Ÿ› ๏ธ Verifying Technical Preferences...") baud = ai.get_personality_value("technical_preferences.james_patterns.serial_baud") safety = ai.get_personality_value("technical_preferences.james_patterns.safety_first") if "115200" in str(baud) and "5000ms" in str(safety): print(f"โœ… Technical Patterns Loaded: Baud {baud}, Safety {safety}") else: print(f"โŒ Technical preferences mismatch") # 6. Verify Interaction Modes print("\n๐Ÿ”„ Verifying Interaction Modes...") modes = ai.get_personality_value("interaction_modes") if modes and "morning_build" in modes and "evening_build" in modes: print(f"โœ… Interaction Modes Loaded: {', '.join(modes.keys())}") else: print("โŒ Interaction modes missing") # 7. Verify Deep Key Access (Advanced Features) print("\n๐Ÿ”‘ Verifying Advanced Features...") shadow_enabled = ai.get_personality_value("advanced_features.shadow_suggestions.enabled") auto_fix = ai.get_personality_value("advanced_features.self_correction.enabled") if shadow_enabled and auto_fix: print("โœ… Advanced features (Shadow Suggestions, Self Correction) enabled") else: print("โŒ Advanced features configuration issue") except Exception as e: print(f"โŒ Error during test: {e}") import traceback traceback.print_exc() if __name__ == "__main__": test_personality_loading()