"""The live-site editor, mounted inside the Studio. The editor is a whole FastAPI app of its own — sessions, ACL, the Joomla write adapter, the fleet console. It is mounted rather than merged so it keeps one implementation: the same code runs standalone on the box that edits a single site, and here as a Studio tab, with no fork to keep in step. Its modules import each other by bare name (`import mesh`), which is what lets them run standalone. Putting this directory on the path preserves that instead of rewriting every import — and none of those names collide with the Studio's, which keeps everything under `core.`. """ import importlib.util import sys from pathlib import Path HERE = Path(__file__).parent if str(HERE) not in sys.path: sys.path.insert(0, str(HERE)) def build(): """The editor's ASGI app, with current runtime seams installed.""" try: spec = importlib.util.spec_from_file_location("kyklos_editor_app", HERE / "app.py") module = importlib.util.module_from_spec(spec) sys.modules[spec.name] = module spec.loader.exec_module(module) try: import migration_routes migration_routes.install(module.app) except Exception as e: print(f"[editor] migration route seam unavailable: {type(e).__name__}: {e}", flush=True) try: import postmeet_routes setattr(postmeet_routes, "editor", module) postmeet_routes.install(module.app, module) except Exception as e: print(f"[editor] PostMeet route seam unavailable: {type(e).__name__}: {e}", flush=True) try: import bridge bridge.install(module.app) except Exception as e: print(f"[editor] Joomla bridge unavailable: {type(e).__name__}: {e}", flush=True) return module.app except Exception as e: print(f"[editor] unavailable: {type(e).__name__}: {e}", flush=True) return None