huge refactor of the entire codebase, with the goal of improving maintainability, readability, and extensibility. This commit includes changes to almost every file in the project, including:

This commit is contained in:
2026-04-19 00:41:09 -07:00
parent d9e736172a
commit bafd37fdfb
50 changed files with 3258 additions and 4177 deletions
+26 -25
View File
@@ -23,7 +23,7 @@ from SYS.config import (
from SYS.database import db
from SYS.logger import log, debug
from Store.registry import _discover_store_classes, _required_keys_for
from ProviderCore.registry import list_providers
from ProviderCore.registry import get_plugin, list_plugins
from TUI.modalscreen.matrix_room_picker import MatrixRoomPicker
from TUI.modalscreen.selection_modal import SelectionModal
import logging
@@ -177,7 +177,7 @@ class ConfigModal(ModalScreen):
with ListView(id="category-list"):
yield ListItem(Label("Global Settings"), id="cat-globals")
yield ListItem(Label("Stores"), id="cat-stores")
yield ListItem(Label("Providers"), id="cat-providers")
yield ListItem(Label("Plugins"), id="cat-providers")
yield ListItem(Label("Tools"), id="cat-tools")
with Vertical(id="config-content"):
@@ -187,7 +187,7 @@ class ConfigModal(ModalScreen):
# Durable synchronous save: waits and verifies DB persisted critical keys
yield Button("Save (durable)", variant="primary", id="save-durable-btn")
yield Button("Add Store", variant="primary", id="add-store-btn")
yield Button("Add Provider", variant="primary", id="add-provider-btn")
yield Button("Add Plugin", variant="primary", id="add-provider-btn")
yield Button("Add Tool", variant="primary", id="add-tool-btn")
yield Button("Back", id="back-btn")
yield Button("Close", variant="error", id="cancel-btn")
@@ -381,10 +381,10 @@ class ConfigModal(ModalScreen):
container.mount(row)
def render_providers(self, container: ScrollableContainer) -> None:
container.mount(Label("Configured Providers", classes="config-label"))
container.mount(Label("Configured Plugins", classes="config-label"))
providers = self.config_data.get("provider", {})
if not providers:
container.mount(Static("No providers configured."))
container.mount(Static("No plugins configured."))
else:
for i, (name, _) in enumerate(providers.items()):
edit_id = f"edit-provider-{i}"
@@ -448,9 +448,9 @@ class ConfigModal(ModalScreen):
# Fetch Provider schema
if item_type == "provider":
from ProviderCore.registry import get_provider_class
from ProviderCore.registry import get_plugin_class
try:
pcls = get_provider_class(item_name)
pcls = get_plugin_class(item_name)
if pcls and hasattr(pcls, "config_schema") and callable(pcls.config_schema):
for field_def in pcls.config_schema():
k = field_def.get("key")
@@ -625,9 +625,9 @@ class ConfigModal(ModalScreen):
# If it's a provider, we might have required keys (legacy check fallback)
if item_type == "provider":
# 2. Legacy required_config_keys
from ProviderCore.registry import get_provider_class
from ProviderCore.registry import get_plugin_class
try:
pcls = get_provider_class(item_name)
pcls = get_plugin_class(item_name)
if pcls:
required_keys = pcls.required_config_keys()
for rk in required_keys:
@@ -886,18 +886,18 @@ class ConfigModal(ModalScreen):
logger.exception("Failed to inspect store class config_schema for '%s'", stype)
self.app.push_screen(SelectionModal("Select Store Type", options), callback=self.on_store_type_selected)
elif bid == "add-provider-btn":
provider_names = list(list_providers().keys())
provider_names = list(list_plugins().keys())
options = []
from ProviderCore.registry import get_provider_class
from ProviderCore.registry import get_plugin_class
for ptype in provider_names:
pcls = get_provider_class(ptype)
pcls = get_plugin_class(ptype)
if pcls and hasattr(pcls, "config_schema") and callable(pcls.config_schema):
try:
if pcls.config_schema():
options.append(ptype)
except Exception:
logger.exception("Failed to inspect provider class config_schema for '%s'", ptype)
self.app.push_screen(SelectionModal("Select Provider Type", options), callback=self.on_provider_type_selected)
self.app.push_screen(SelectionModal("Select Plugin Type", options), callback=self.on_provider_type_selected)
elif bid == "add-tool-btn":
# Discover tool modules that advertise a config_schema()
options = []
@@ -1067,9 +1067,9 @@ class ConfigModal(ModalScreen):
# For providers, they are usually top-level entries in 'provider' dict
if ptype not in self.config_data["provider"]:
from ProviderCore.registry import get_provider_class
from ProviderCore.registry import get_plugin_class
try:
pcls = get_provider_class(ptype)
pcls = get_plugin_class(ptype)
new_config = {}
if pcls:
# Use schema for defaults
@@ -1273,9 +1273,9 @@ class ConfigModal(ModalScreen):
@work(thread=True)
def _matrix_test_background(self) -> None:
try:
from Provider.matrix import Matrix
provider = Matrix(self.config_data)
provider = get_plugin("matrix", self.config_data)
if provider is None:
raise RuntimeError("Matrix plugin unavailable")
rooms = provider.list_rooms()
self.app.call_from_thread(self._matrix_test_result, True, rooms, None)
except Exception as exc:
@@ -1433,9 +1433,9 @@ class ConfigModal(ModalScreen):
@work(thread=True)
def _matrix_load_background(self) -> None:
try:
from Provider.matrix import Matrix
provider = Matrix(self.config_data)
provider = get_plugin("matrix", self.config_data)
if provider is None:
raise RuntimeError("Matrix plugin unavailable")
rooms = provider.list_rooms()
self.app.call_from_thread(self._matrix_load_result, True, rooms, None)
except Exception as exc:
@@ -1626,8 +1626,9 @@ class ConfigModal(ModalScreen):
return []
try:
from Provider.matrix import Matrix
provider = Matrix(self.config_data)
provider = get_plugin("matrix", self.config_data)
if provider is None:
return []
rooms = provider.list_rooms(room_ids=ids_list)
return rooms or []
except Exception as exc:
@@ -1870,9 +1871,9 @@ class ConfigModal(ModalScreen):
required_keys = list(_required_keys_for(classes[stype]))
section = self.config_data.get("store", {}).get(stype, {}).get(item_name, {})
elif item_type == "provider":
from ProviderCore.registry import get_provider_class
from ProviderCore.registry import get_plugin_class
try:
pcls = get_provider_class(item_name)
pcls = get_plugin_class(item_name)
if pcls:
# Collect required keys from schema
if hasattr(pcls, "config_schema") and callable(pcls.config_schema):