from pathlib import Path import re file_path = Path('src/app_controller.py') code = file_path.read_text(encoding='utf-8') # 1. Inject show_windows code = re.sub( r'(self\._pending_gui_tasks_lock: threading\.Lock = threading\.Lock\(\))', r'\1\n self.show_windows: Dict[str, bool] = {}', code ) # 2. Inject ui_active_persona and ui_active_bias_profile code = re.sub( r'(self\.ui_ai_input: str = "")', r'self.ui_active_persona: str = ""\n self.ui_active_bias_profile: str | None = None\n \1', code ) # 3. Add ui_active_persona to _settable_fields code = re.sub( r"('disc_new_role_input': 'ui_disc_new_role_input',)", r"\1\n 'active_persona': 'ui_active_persona',", code ) file_path.write_text(code, encoding='utf-8') print("Precision injection complete.")