Files
hermes-agent/workspace/__init__.py
T
alt-glitch 4921bad61f style(workspace): remove __future__ annotations, fix ty diagnostics
- Remove `from __future__ import annotations` from all new workspace files
- Convert TYPE_CHECKING imports to real imports in base.py (no circular deps)
- Quote self-referential forward ref in config.py model_validator
- Add null checks on spec.loader in plugin discovery to satisfy ty
2026-04-18 15:58:54 +05:30

47 lines
1.1 KiB
Python

"""Workspace indexing and search.
Public API:
get_indexer(config) -> BaseIndexer
load_workspace_config() -> WorkspaceConfig
"""
import logging
from workspace.base import BaseIndexer
from workspace.config import WorkspaceConfig, load_workspace_config
from workspace.default import DefaultIndexer
from workspace.types import IndexingError, IndexSummary, SearchResult
log = logging.getLogger(__name__)
def get_indexer(config: WorkspaceConfig | None = None) -> BaseIndexer:
if config is None:
config = load_workspace_config()
if config.indexer == "default":
return DefaultIndexer(config)
try:
from plugins.workspace import load_workspace_indexer
cls = load_workspace_indexer(config.indexer)
except ImportError:
cls = None
if cls is None:
log.warning(
"Indexer plugin '%s' not found, falling back to default", config.indexer
)
return DefaultIndexer(config)
return cls(config)
__all__ = [
"BaseIndexer",
"DefaultIndexer",
"WorkspaceConfig",
"load_workspace_config",
"get_indexer",
"IndexingError",
"IndexSummary",
"SearchResult",
]