Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/CLI_REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,7 @@ Rebuild the vector search index by re-embedding all wiki pages. No LLM calls, on
|------|-------------|
| `--embedder` | `gemini`, `openai`, `openrouter`, `ollama`, `mock`, or `auto` (default: auto) |
| `--batch-size` | Embedding batch size (default: 32) |
| `--verbose`, `-v` | Show debug logs from the pipeline |

```bash
repowise reindex
Expand Down
16 changes: 15 additions & 1 deletion packages/cli/src/repowise/cli/commands/reindex_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import click
from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn, TimeElapsedColumn

from repowise.cli._setup import configure_cli_logging
from repowise.cli.helpers import (
console,
ensure_repowise_dir,
Expand All @@ -24,13 +25,26 @@
help="Embedder to use. 'auto' detects from env vars / config.",
)
@click.option("--batch-size", type=int, default=32, help="Pages per embedding batch.")
def reindex_command(path: str | None, embedder: str, batch_size: int) -> None:
@click.option(
"--verbose",
"-v",
is_flag=True,
default=False,
help="Show debug logs from the pipeline.",
)
def reindex_command(
path: str | None, embedder: str, batch_size: int, verbose: bool = False
) -> None:
"""Rebuild vector search index from existing wiki pages.

Reads all pages from the database, embeds them using the configured
embedder, and persists the vectors to LanceDB. No LLM calls — only
embedding API calls. Fast and cheap.
"""
# Quiet library/structlog output so it doesn't interleave with the live
# progress bar; `-v` lets repowise's debug lines through for troubleshooting.
configure_cli_logging(verbose=verbose)

repo_path = resolve_repo_path(path)
ensure_repowise_dir(repo_path)

Expand Down
24 changes: 24 additions & 0 deletions tests/unit/cli/test_reindex_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,27 @@ async def fake_init_db(engine: object) -> None:
assert created["url"] == db_url
assert created["init_engine"] is created["engine"]
assert created["engine"].disposed is True


def test_reindex_verbose_flag_reaches_configure_cli_logging(tmp_path, monkeypatch):
"""`--verbose/-v` must reach configure_cli_logging via CliRunner (not .callback)."""
from click.testing import CliRunner
from repowise.cli.main import cli

calls: list[bool] = []
monkeypatch.setattr(
reindex_cmd, "configure_cli_logging", lambda *, verbose: calls.append(verbose)
)
monkeypatch.setattr(reindex_cmd, "resolve_repo_path", lambda _p: tmp_path)
monkeypatch.setattr(reindex_cmd, "ensure_repowise_dir", lambda _p: tmp_path / ".repowise")
monkeypatch.setattr(reindex_cmd, "run_async", lambda coro: coro.close())
monkeypatch.setattr("repowise.cli.ui.load_dotenv", lambda _repo_path: None)

result = CliRunner().invoke(cli, ["reindex", str(tmp_path), "-v"])
assert result.exit_code == 0, result.output
assert calls == [True]

calls.clear()
result = CliRunner().invoke(cli, ["reindex", str(tmp_path)])
assert result.exit_code == 0, result.output
assert calls == [False]