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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! Knowledge-base CLI subcommands. Spec ยง5 V1.
use clap::Subcommand;
#[derive(Subcommand, Debug)]
pub enum KbCommand {
/// Add a document (file path, directory, or URL) to the knowledge base.
Add {
/// File path, directory, or URL (http://, https://).
path_or_url: String,
#[arg(long)]
tags: Vec<String>,
/// When `path_or_url` is a directory, recursively ingest
/// every file matching `--ext` (default: md,txt,html,pdf).
#[arg(long)]
recursive: bool,
/// Comma-separated extensions to ingest in recursive mode.
#[arg(long, default_value = "md,txt,html,pdf")]
ext: String,
},
/// List documents.
Ls {
#[arg(long)]
tag: Vec<String>,
#[arg(long)]
source_kind: Option<String>,
#[arg(long, default_value_t = 50)]
limit: usize,
},
/// Remove a document by id, or all docs matching a tag.
Rm {
/// Doc id to tombstone. Omit when using --tag.
doc_id: Option<String>,
/// Tombstone every Active doc with this tag (bulk delete).
#[arg(long)]
tag: Option<String>,
/// Skip the confirmation guard (required for tombstone).
#[arg(long)]
yes: bool,
},
/// Search the knowledge base.
Search {
query: String,
#[arg(short, long, default_value_t = 8)]
k: usize,
/// Emit the full KbSearchOutput as JSON (machine consumption).
#[arg(long)]
json: bool,
},
/// Show a chunk or doc by id.
Show { id: String },
/// Update document visibility.
Visibility {
doc_id: String,
/// One of: global | private | agent:<id> | channel:<id>
visibility: String,
},
/// Run a compactor tick (orphan cleanup + ledger advance).
Compact,
/// Show kb stats (doc/chunk counts, disk usage).
Stats,
/// Export a doc's markdown body to a path.
Export {
doc_id: String,
#[arg(long)]
to: std::path::PathBuf,
},
/// Re-sync all URL-sourced Active docs whose last sync is stale.
SyncAll {
/// Skip docs whose last_sync_at is newer than this many minutes ago.
#[arg(long, default_value_t = 20)]
interval_min: u64,
/// Cap the number of URLs synced this tick (rate-limit guard).
#[arg(long, default_value_t = 50)]
max: usize,
/// Print what would run without doing it.
#[arg(long)]
dry_run: bool,
},
}