diff --git a/src/cli/main.py b/src/cli/main.py index 2562d1e..856721d 100644 --- a/src/cli/main.py +++ b/src/cli/main.py @@ -63,6 +63,8 @@ def ingest( typer.Argument(help="Markdown 文件路径 (可多个, 或 - 从标准输入读取)"), ] = None, name: Annotated[str | None, typer.Option("--name", help="标准输入模式下的虚拟文件名")] = None, + incremental: Annotated[bool, typer.Option("--incremental", help="增量模式:跳过未变更文件")] = False, + force: Annotated[bool, typer.Option("--force", help="强制重新入库(忽略增量检查)")] = False, config: ConfigOpt = DEFAULT_CONFIG_PATH, collection: CollectionOpt = None, ): @@ -93,11 +95,11 @@ def ingest( if not is_safe_cli_path(m): typer.echo(f"[SKIP] 不安全的路径: {m}", err=True) continue - c = ingestor.ingest_file(m) + c = ingestor.ingest_file(m, incremental=incremental, force=force) typer.echo(f" {m}: {c} chunks") total += c elif p.is_file(): - c = ingestor.ingest_file(fp) + c = ingestor.ingest_file(fp, incremental=incremental, force=force) typer.echo(f" {fp}: {c} chunks") total += c else: @@ -137,12 +139,15 @@ def search( query: Annotated[str, typer.Argument(help="搜索关键词或自然语言查询")], top_k: Annotated[int, typer.Option("--top-k", "-k", help="返回结果数量 (1-100)")] = 10, json_output: Annotated[bool, typer.Option("--json", help="以 JSON 格式输出")] = False, + mode: Annotated[str, typer.Option("--mode", help="检索模式: hybrid | vector")] = "", config: ConfigOpt = DEFAULT_CONFIG_PATH, collection: CollectionOpt = None, ): _init_config(config) state = get_state() searcher = state.get_searcher(_resolve_collection(collection)) + if mode: + searcher._search_config.mode = mode results = searcher.search(query, top_k=top_k) if json_output: