From 30b29108288954b37a6421128cece48815c92af9 Mon Sep 17 00:00:00 2001 From: Santhosh Janardhanan Date: Mon, 13 Apr 2026 14:34:51 -0400 Subject: [PATCH] feat: add indexer CLI with index, sync, reindex, status commands --- src/companion/indexer_daemon/__init__.py | 0 src/companion/indexer_daemon/cli.py | 57 ++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/companion/indexer_daemon/__init__.py create mode 100644 src/companion/indexer_daemon/cli.py diff --git a/src/companion/indexer_daemon/__init__.py b/src/companion/indexer_daemon/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/companion/indexer_daemon/cli.py b/src/companion/indexer_daemon/cli.py new file mode 100644 index 0000000..3d31022 --- /dev/null +++ b/src/companion/indexer_daemon/cli.py @@ -0,0 +1,57 @@ +from __future__ import annotations + +from pathlib import Path + +import typer + +from companion.config import load_config +from companion.rag.indexer import Indexer +from companion.rag.vector_store import VectorStore + +app = typer.Typer(help="Companion vault indexer") + + +def _get_indexer() -> Indexer: + config = load_config("config.json") + store = VectorStore( + uri=config.rag.vector_store.path, dimensions=config.rag.embedding.dimensions + ) + return Indexer(config, store) + + +@app.command() +def index() -> None: + """Run a full index of the vault.""" + indexer = _get_indexer() + typer.echo("Running full index...") + indexer.full_index() + typer.echo(f"Done. Total chunks: {indexer.status()['total_chunks']}") + + +@app.command() +def sync() -> None: + """Run an incremental sync.""" + indexer = _get_indexer() + typer.echo("Running incremental sync...") + indexer.sync() + typer.echo(f"Done. Total chunks: {indexer.status()['total_chunks']}") + + +@app.command() +def reindex() -> None: + """Force a full reindex (same as index).""" + index() + + +@app.command() +def status() -> None: + """Show indexer status.""" + indexer = _get_indexer() + s = indexer.status() + typer.echo(f"Total chunks: {s['total_chunks']}") + typer.echo(f"Indexed files: {s['indexed_files']}") + typer.echo(f"Unindexed files: {s['unindexed_files']}") + + +if __name__ == "__main__": + app()