indexlocate.py¶
clew/indexlocate.py
Find the index already built for a repository, without building one.
find_index
Path | None clew.indexlocate.find_index(Path repo_root, str|None explicit=None)
The existing index for a repository.
Source · 9 lines
def find_index(repo_root: Path, explicit: str | None = None) -> Path | None:
"""@brief Find the index. @return Path or None."""
if explicit:
candidate = Path(explicit).expanduser().resolve()
return candidate if candidate.is_file() else None
local = repo_root / "clew.db"
return registered_index(repo_root) or (local if local.is_file() else None)
Activity · 5 steps
Requirements
Flows
registered_index
Path | None clew.indexlocate.registered_index(Path repo_root)
The database the MCP target registry has allocated for a repository.
Source · 18 lines
def registered_index(repo_root: Path) -> Path | None:
"""IMPORTED LAZILY AND GUARDED: the registry lives under `mcp_server`, whose package import
pulls the optional MCP SDK. A core-only install still runs; it just cannot find an
agent-built database.
@brief Registered database.
@return Path or None.
"""
try:
from .mcp_server.state import TargetRegistry
except ImportError:
return None
wanted = str(Path(repo_root).expanduser().resolve())
for target in TargetRegistry().targets():
path = Path(target.db_path)
if str(Path(target.repo_path).expanduser().resolve()) == wanted and path.is_file():
return path
return None1 more lines, not shown