"""Module discovery. Every `deckit/modules/.py` exporting `make(cfg) -> Module` is a module. Discovery is lazy and file-based, so a new module is a new file: nothing here lists the modules, and a not-yet-written one simply stays absent. """ import importlib from pathlib import Path from ..module import Registry def build(cfg: dict) -> Registry: enabled = cfg.get("modules", {}) modules = [] for path in sorted(Path(__file__).parent.glob("*.py")): name = path.stem if name == "__init__" or not enabled.get(name, True): continue try: mod = importlib.import_module(f"{__name__}.{name}") except ImportError: continue modules.append(mod.make(cfg)) return Registry(modules)