#!/usr/bin/env python3 """ Glyph Explorer - Interactive Glyph System Explorer Explore 600 glyphs with 152 superpowers, test activation, view power boosts, and verify the dual-layer symbolic system. Usage: python3 glyph_explorer.py [command] [options] Commands: list List glyphs (default: 20) show Show glyph details by ID powers Show superpowers for a glyph activate Test glyph activation boost Calculate power boost search Search glyphs by name/category stats Show system statistics test Run all tests help Show this help """ import sys import json from pathlib import Path from typing import Dict, List, Any, Optional sys.path.insert(0, str(Path(__file__).parent)) from glyphs import ( load_all_supercharged, get_super, list_super_ids, super_stats, search_super, assign_superpowers, calculate_boost, get_superpower, list_superpower_ids, load_all_superpowers, ) def print_header(title: str): """Print header with decorative border.""" width = 70 print("\n" + "=" * width) print(f" {title}") print("=" * width) def cmd_list(args: List[str]): """List glyphs.""" load_all_supercharged() stats = super_stats() limit = 20 if args and args[0].isdigit(): limit = int(args[0]) print_header(f"GLYPHS ({stats['total_glyphs']} total, showing {limit})") for glyph_id in stats['sample_ids'][:limit]: glyph = get_super(glyph_id) name = glyph.get('name', 'Unknown') category = glyph.get('category', 'Unknown') score = glyph.get('score', 0) band = glyph.get('band', 0) powers_count = len(glyph.get('superpowers', [])) print(f"{glyph_id}: {name:20s} | {category:15s} | Score: {score:4d} | Band: {band} | Powers: {powers_count}") def cmd_show(args: List[str]): """Show glyph details.""" if not args: print("Usage: show ") return glyph_id = args[0].upper() load_all_supercharged() glyph = get_super(glyph_id) if not glyph: print(f"Glyph {glyph_id} not found") return print_header(f"GLYPH {glyph_id} DETAILS") print(f"Name: {glyph.get('name', 'Unknown')}") print(f"Category: {glyph.get('category', 'Unknown')}") print(f"Period: {glyph.get('period', 'N/A')}") print(f"Band: {glyph.get('band', 'N/A')}") print(f"Score: {glyph.get('score', 0)}") print(f"Superpowers: {len(glyph.get('superpowers', []))}") print("\nMetrics:") metrics = glyph.get('originalMetrics', {}) for key, val in metrics.items(): print(f" {key}: {val}") print("\nPRAW:") praw = glyph.get('praw', {}) for key, val in praw.items(): print(f" {key}: {val}") print("\nLineage:") lineage = glyph.get('lineage', {}) print(f" Signature: {lineage.get('signature', 'N/A')}") print(f" Inheritance Weight: {lineage.get('inheritanceWeight', 'N/A')}") print("\nActivation:") activation = glyph.get('activation', {}) print(f" Current Mode: {activation.get('currentMode', 'N/A')}") print(f" Score: {activation.get('score', 'N/A')}") print("\nRouting:") routing = glyph.get('routing', {}) print(f" Base Weight: {routing.get('baseWeight', 'N/A')}") print("\nStorage:") storage = glyph.get('storage', {}) print(f" Type: {storage.get('type', 'N/A')}") print("\nGovernance:") governance = glyph.get('governance', {}) print(f" Status: {governance.get('status', 'N/A')}") def cmd_powers(args: List[str]): """Show superpowers for a glyph.""" if not args: print("Usage: powers ") return glyph_id = args[0].upper() load_all_supercharged() glyph = get_super(glyph_id) if not glyph: print(f"Glyph {glyph_id} not found") return powers = glyph.get('superpowers', []) print_header(f"GLYPH {glyph_id} SUPERPOWERS ({len(powers)} total)") if not powers: print("No superpowers assigned") return load_all_superpowers() for i, sp_id in enumerate(powers[:20], 1): sp = get_superpower(sp_id) name = sp.get('name', 'Unknown') boost = sp.get('boost_percent', 0) band = sp.get('band', 'N/A') print(f"{i:3d}. [{band}] {name:40s} +{boost}%") if len(powers) > 20: print(f"... and {len(powers) - 20} more") def cmd_activate(args: List[str]): """Test glyph activation.""" if not args: print("Usage: activate ") return glyph_id = args[0].upper() load_all_supercharged() glyph = get_super(glyph_id) if not glyph: print(f"Glyph {glyph_id} not found") return metrics = glyph.get('originalMetrics', {}) specialized = glyph.get('specialized_type', '') category = glyph.get('category', '') assigned = assign_superpowers(glyph_id, metrics, specialized, category) boost = calculate_boost(assigned) print_header(f"GLYPH {glyph_id} ACTIVATION TEST") print(f"Glyph: {glyph.get('name')}") print(f"Category: {category}") print(f"Specialized: {specialized or 'None'}") print(f"\nSuperpowers Assigned: {len(assigned)}") print(f"Power Boost Multiplier: {boost:.2f}x") print(f"Boost Percentage: {int((boost - 1) * 100)}%") if glyph_id == 'G001': print("\n⚠️ G001 (Ledo/Aether Node) - All 152 superpowers active!") print(" This is the primordial root glyph with universal authority.") # Simulate activation print(f"\n✅ Activation successful!") print(f" VRAM Budget: 7.5GB (max for GTX 1080)") print(f" Priority: 10.0 (maximum)") print(f" Constraints: None (primordial authority)") print(f" Enhancements: universal_override, primordial_resonance, system_root_access") def cmd_boost(args: List[str]): """Calculate power boost.""" if not args: print("Usage: boost ") return glyph_id = args[0].upper() load_all_supercharged() glyph = get_super(glyph_id) if not glyph: print(f"Glyph {glyph_id} not found") return metrics = glyph.get('originalMetrics', {}) specialized = glyph.get('specialized_type', '') category = glyph.get('category', '') assigned = assign_superpowers(glyph_id, metrics, specialized, category) boost = calculate_boost(assigned) print_header(f"POWER BOOST CALCULATION - {glyph_id}") print(f"Assigned Superpowers: {len(assigned)}") print(f"Power Boost Multiplier: {boost:.2f}x") print(f"Effectiveness Increase: {int((boost - 1) * 100)}%") def cmd_search(args: List[str]): """Search glyphs.""" if not args: print("Usage: search ") return query = args[0].lower() load_all_supercharged() results = search_super(query, fields=['name', 'category'], limit=20) print_header(f"SEARCH RESULTS for '{query}' ({len(results)} found)") for glyph in results: glyph_id = glyph.get('id', 'Unknown') name = glyph.get('name', 'Unknown') category = glyph.get('category', 'Unknown') score = glyph.get('score', 0) print(f"{glyph_id}: {name:20s} | {category:15s} | Score: {score}") def cmd_stats(args: List[str]): """Show system statistics.""" load_all_supercharged() load_all_superpowers() stats = super_stats() glyph_ids = list_super_ids() print_header("SYSTEM STATISTICS") print(f"Glyphs Loaded: {stats['total_glyphs']}") print(f"Categories: {len(stats['categories'])}") print(f"Superpowers Loaded: {len(glyph_ids)}") # Calculate aggregate stats total_assigned = 0 max_boost = 0 max_boost_glyph = '' for glyph_id in stats['sample_ids'][:10]: glyph = get_super(glyph_id) metrics = glyph.get('originalMetrics', {}) specialized = glyph.get('specialized_type', '') category = glyph.get('category', '') assigned = assign_superpowers(glyph_id, metrics, specialized, category) boost = calculate_boost(assigned) total_assigned += len(assigned) if boost > max_boost: max_boost = boost max_boost_glyph = glyph_id print(f"\nSample Analysis (10 glyphs):") print(f" Total Assigned Powers: {total_assigned}") print(f" Max Boost: {max_boost:.2f}x ({max_boost_glyph})") # G001 special print(f"\nG001 (Ledo/Aether Node):") g001 = get_super('G001') g001_metrics = g001.get('originalMetrics', {}) g001_assigned = assign_superpowers('G001', g001_metrics, '', '') g001_boost = calculate_boost(g001_assigned) print(f" Superpowers: {len(g001_assigned)} (ALL)") print(f" Boost: {g001_boost:.2f}x") def cmd_test(args: List[str]): """Run all tests.""" print_header("RUNNING TESTS") tests_passed = 0 tests_failed = 0 # Test 1: Load all glyphs try: load_all_supercharged() stats = super_stats() assert stats['total_glyphs'] == 600, f"Expected 600 glyphs, got {stats['total_glyphs']}" print("✅ Test 1: Load 600 glyphs - PASSED") tests_passed += 1 except Exception as e: print(f"❌ Test 1: Load 600 glyphs - FAILED: {e}") tests_failed += 1 # Test 2: Load all superpowers try: load_all_superpowers() ids = list_superpower_ids() assert len(ids) == 152, f"Expected 152 superpowers, got {len(ids)}" print("✅ Test 2: Load 152 superpowers - PASSED") tests_passed += 1 except Exception as e: print(f"❌ Test 2: Load 152 superpowers - FAILED: {e}") tests_failed += 1 # Test 3: G001 has all superpowers try: g001 = get_super('G001') assert len(g001.get('superpowers', [])) == 152, f"G001 should have 152 superpowers" print("✅ Test 3: G001 has 152 superpowers - PASSED") tests_passed += 1 except Exception as e: print(f"❌ Test 3: G001 has 152 superpowers - FAILED: {e}") tests_failed += 1 # Test 4: G002 has limited superpowers try: g002 = get_super('G002') raw_count = len(g002.get('superpowers', [])) assert raw_count <= 22, f"G002 should have <=22 superpowers, got {raw_count}" print("✅ Test 4: G002 has limited superpowers - PASSED") tests_passed += 1 except Exception as e: print(f"❌ Test 4: G002 has limited superpowers - FAILED: {e}") tests_failed += 1 # Test 5: Power boost calculation try: g001 = get_super('G001') metrics = g001.get('originalMetrics', {}) assigned = assign_superpowers('G001', metrics, '', '') boost = calculate_boost(assigned) assert boost > 300, f"G001 boost should be >300x, got {boost}" print(f"✅ Test 5: Power boost calculation - PASSED ({boost:.2f}x)") tests_passed += 1 except Exception as e: print(f"❌ Test 5: Power boost calculation - FAILED: {e}") tests_failed += 1 # Test 6: Search functionality try: results = search_super('neural', limit=5) assert len(results) > 0, "Search should return results" print(f"✅ Test 6: Search functionality - PASSED ({len(results)} results)") tests_passed += 1 except Exception as e: print(f"❌ Test 6: Search functionality - FAILED: {e}") tests_failed += 1 # Test 7: Glyph activation try: g002 = get_super('G002') metrics = g002.get('originalMetrics', {}) assigned = assign_superpowers('G002', metrics, '', '') assert len(assigned) > 0, "Should assign at least one superpower" print(f"✅ Test 7: Glyph activation - PASSED ({len(assigned)} powers)") tests_passed += 1 except Exception as e: print(f"❌ Test 7: Glyph activation - FAILED: {e}") tests_failed += 1 print_header("TEST SUMMARY") print(f"Passed: {tests_passed}") print(f"Failed: {tests_failed}") print(f"Total: {tests_passed + tests_failed}") if tests_failed == 0: print("\n✅ ALL TESTS PASSED") return 0 else: print(f"\n❌ {tests_failed} test(s) failed") return 1 def main(): """Main entry point.""" if len(sys.argv) < 2: print(__doc__) return cmd = sys.argv[1].lower() args = sys.argv[2:] commands = { 'list': cmd_list, 'show': cmd_show, 'powers': cmd_powers, 'activate': cmd_activate, 'boost': cmd_boost, 'search': cmd_search, 'stats': cmd_stats, 'test': cmd_test, 'help': lambda _: print(__doc__), } if cmd in commands: result = commands[cmd](args) if result is not None: sys.exit(result) else: print(f"Unknown command: {cmd}") print("Use 'help' for usage information") sys.exit(1) if __name__ == "__main__": main()