diff --git a/docs/CLI_REFERENCE.md b/docs/CLI_REFERENCE.md index 2e0ce847f..eb70aa9be 100644 --- a/docs/CLI_REFERENCE.md +++ b/docs/CLI_REFERENCE.md @@ -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 diff --git a/packages/cli/src/repowise/cli/commands/reindex_cmd.py b/packages/cli/src/repowise/cli/commands/reindex_cmd.py index c2e8a7d4b..262243a26 100644 --- a/packages/cli/src/repowise/cli/commands/reindex_cmd.py +++ b/packages/cli/src/repowise/cli/commands/reindex_cmd.py @@ -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, @@ -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) diff --git a/tests/unit/cli/test_reindex_cmd.py b/tests/unit/cli/test_reindex_cmd.py index 639bab080..5e8f8d4be 100644 --- a/tests/unit/cli/test_reindex_cmd.py +++ b/tests/unit/cli/test_reindex_cmd.py @@ -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]