1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! Handler for `trusty-search search`.
//!
//! Why: `search` is the project-scoped sibling of `query` — when the working
//! directory is inside a registered index, callers prefer `search` because it
//! auto-resolves the target index from CWD and skips the cross-repo fan-out.
//! Historically the handler was a placeholder that printed
//! "Daemon connection not yet implemented" (issue #3). Issue #65 wires it to
//! the same daemon path used by `query` so the two commands share the
//! `/indexes/:id/search` POST and a single render routine.
//! What: resolve the target index (explicit `--index` flag wins, otherwise the
//! CWD-detected id from `resolve_index`), then delegate to
//! `commands::query::handle_query` which performs the daemon round-trip and
//! prints the result list. `top_k` is forwarded verbatim; `full`/`intent`/
//! `no_kg`/`offset`/`budget` are accepted from the CLI for forward
//! compatibility but the unsupported subset is silently ignored — wiring them
//! is a follow-up once the daemon exposes the matching knobs.
//! Test: `search_delegates_to_query_with_explicit_index` covers the index-id
//! plumbing without touching the network.
use resolve_index;
use Result;
/// Why: see module docs. Keeping the same arity (and `#[allow]`) lets the
/// `main.rs` call site stay largely unchanged after the issue #65 wiring.
/// What: resolves the target index id (explicit > CWD-detected), wraps it in
/// the `Option<String>` shape `handle_query` expects, and delegates to
/// `handle_query` so the two subcommands share one code path. `indexes = "*"`
/// is passed as a sentinel because the explicit id is already supplied so the
/// multi-index resolution branch in `handle_query` is unreachable. `json`
/// is forwarded from the caller so `--json` output is honoured (issue #3 / Bug #3).
/// Test: `search_delegates_to_query_with_explicit_index` + `search_forwards_json_flag`.
pub async