trusty-search 0.3.6

Machine-wide hybrid code search service: BM25 + vector + KG, zero cold-start, MCP server
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Handler for `trusty-search add <file>`.

use crate::{add_path, daemon_base_url, print_index_header, resolve_index};
use anyhow::Result;

/// Why: thin wrapper so `main()` doesn't need to know about `add_path` (which
/// handles both single-file and directory walks). Auto-starts the daemon if
/// it isn't running — `add` always talks to it.
/// What: resolves the active index, prints header, ensures the daemon is up,
/// delegates to `add_path`.
/// Test: `cargo run -- add src/main.rs` POSTs to `/indexes/<id>/index-file`.
pub async fn handle_add(explicit_index: &Option<String>, file: std::path::PathBuf) -> Result<()> {
    let (index_id, warned) = resolve_index(explicit_index);
    print_index_header(&index_id, warned);
    crate::commands::daemon_guard::ensure_daemon_running_or_exit(&daemon_base_url()).await;
    add_path(&index_id, &file).await
}