diff --git a/docs/cli.md b/docs/cli.md index 416c4d4f..afe303a1 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -54,16 +54,14 @@ haiku-rag add-src /mnt/data/doc1.pdf --meta source=manual --meta page_count=12 - ### Get Document ```bash -haiku-rag get -# or -haiku-rag get 3f4a... # document ID (autocomplete supported) +haiku-rag get 3f4a... # document ID ``` ### Delete Document ```bash -haiku-rag delete -haiku-rag rm # alias +haiku-rag delete 3f4a... # document ID +haiku-rag rm 3f4a... # alias ``` Use this when you want to change things like the embedding model or chunk size for example. @@ -212,20 +210,3 @@ This will: - Optimize the new database for best performance The original SQLite database remains unchanged, so you can safely migrate without risk of data loss. - -## Shell Autocompletion - -Enable shell autocompletion for faster, error‑free usage. - -- Temporary (current shell only): - ```bash - eval "$(haiku-rag --show-completion)" - ``` -- Permanent installation: - ```bash - haiku-rag --install-completion - ``` - -What’s completed: -- `get` and `delete`/`rm`: Document IDs from the selected database (respects `--db`). -- `add-src`: Local filesystem paths (URLs can still be typed manually). diff --git a/src/haiku/rag/cli.py b/src/haiku/rag/cli.py index 62ecf660..ab46e3ac 100644 --- a/src/haiku/rag/cli.py +++ b/src/haiku/rag/cli.py @@ -16,65 +16,6 @@ cli = typer.Typer( ) -def complete_document_ids(ctx: typer.Context, incomplete: str): - """Autocomplete document IDs from the selected DB.""" - db_path = ctx.params.get("db") or (Config.DEFAULT_DATA_DIR / "haiku.rag.lancedb") - - try: - from haiku.rag.client import HaikuRAG - - async def _list_ids(): - async with HaikuRAG(db_path) as client: - docs = await client.list_documents() - return [d.id for d in docs if d.id] - - ids = asyncio.run(_list_ids()) - except Exception: - return [] - - return [i for i in ids if i and i.startswith(incomplete)] - - -def complete_local_paths(ctx: typer.Context, incomplete: str) -> list[str]: - """Autocomplete local filesystem paths. - - Provides directory/file suggestions based on the current incomplete input. - Does not validate or restrict to specific extensions to keep it flexible - (URLs are still allowed to be typed manually). - """ - try: - text = incomplete or "" - - # Expand user home - from os.path import expanduser - - expanded = expanduser(text) - p = Path(expanded) - - # Choose directory to list and prefix to filter - if text == "" or text.endswith(("/", "\\")): - directory = p - prefix = "" - else: - directory = p.parent - prefix = p.name - - if not directory.exists(): - return [] - - suggestions: list[str] = [] - for entry in directory.iterdir(): - name = entry.name - if not prefix or name.startswith(prefix): - suggestion = str(directory / name) - if entry.is_dir(): - suggestion += "/" - suggestions.append(suggestion) - return suggestions - except Exception: - return [] - - async def check_version(): """Check if haiku.rag is up to date and show warning if not.""" up_to_date, current_version, latest_version = await is_up_to_date() @@ -191,7 +132,6 @@ def add_document_text( def add_document_src( source: str = typer.Argument( help="The file path or URL of the document to add", - autocompletion=complete_local_paths, ), title: str | None = typer.Option( None, @@ -225,7 +165,6 @@ def add_document_src( def get_document( doc_id: str = typer.Argument( help="The ID of the document to get", - autocompletion=complete_document_ids, ), db: Path = typer.Option( Config.DEFAULT_DATA_DIR / "haiku.rag.lancedb", @@ -243,7 +182,6 @@ def get_document( def delete_document( doc_id: str = typer.Argument( help="The ID of the document to delete", - autocompletion=complete_document_ids, ), db: Path = typer.Option( Config.DEFAULT_DATA_DIR / "haiku.rag.lancedb",