Skip to content

Commit a67849a

Browse files
devwhodevsclaude
andcommitted
feat: show intent in --explain output and intelligence state in status
- run_search: prepend "Intent: <variant>" before the explain lane breakdown when --explain is used - run_status / format_status: load Config, derive intelligence enabled/disabled, include in both human-readable and JSON status output - Updated format_status signature to accept `intelligence: &str`; updated both call sites and both unit tests (added assertions for the new field) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 085db23 commit a67849a

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

src/search.rs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,11 @@ pub fn run_search(
319319
let mut out = format_results(&results, json);
320320

321321
if explain && !json {
322-
let mut explain_out = String::from("\n--- Explain ---\n");
322+
let mut explain_out = String::new();
323+
if let Some(ref intent) = output.intent {
324+
explain_out.push_str(&format!("Intent: {:?}\n\n", intent));
325+
}
326+
explain_out.push_str("--- Explain ---\n");
323327
for f in output.fused.iter().take(top_n) {
324328
explain_out.push_str(&format!("{}\n", f.file_path));
325329
explain_out.push_str(&fusion::format_explain(f));
@@ -342,7 +346,10 @@ pub fn run_status(json: bool, data_dir: &Path) -> Result<()> {
342346

343347
let model_name = "all-MiniLM-L6-v2";
344348

345-
let output = format_status(&stats, index_size, model_name, json);
349+
let config = crate::config::Config::load().unwrap_or_default();
350+
let intelligence = if config.intelligence_enabled() { "enabled" } else { "disabled" };
351+
352+
let output = format_status(&stats, index_size, model_name, intelligence, json);
346353
print!("{output}");
347354
Ok(())
348355
}
@@ -402,7 +409,13 @@ pub fn format_results(results: &[SearchResult], json: bool) -> String {
402409
}
403410

404411
/// Format status information for display (pure function, no I/O).
405-
pub fn format_status(stats: &StoreStats, index_size: u64, model_name: &str, json: bool) -> String {
412+
pub fn format_status(
413+
stats: &StoreStats,
414+
index_size: u64,
415+
model_name: &str,
416+
intelligence: &str,
417+
json: bool,
418+
) -> String {
406419
let vault = stats.vault_path.as_deref().unwrap_or("<not set>");
407420
let last_indexed = stats.last_indexed_at.as_deref().unwrap_or("never");
408421

@@ -415,6 +428,7 @@ pub fn format_status(stats: &StoreStats, index_size: u64, model_name: &str, json
415428
"last_indexed": last_indexed,
416429
"index_size": index_size,
417430
"model": model_name,
431+
"intelligence": intelligence,
418432
});
419433
if let (Some(edges), Some(wl), Some(mn)) =
420434
(stats.edge_count, stats.wikilink_count, stats.mention_count)
@@ -443,11 +457,13 @@ pub fn format_status(stats: &StoreStats, index_size: u64, model_name: &str, json
443457
"Tombstones: {} (pending cleanup)\n\
444458
Last index: {}\n\
445459
Index size: {}\n\
446-
Model: {}\n",
460+
Model: {}\n\
461+
Intelligence: {}\n",
447462
stats.tombstone_count,
448463
last_indexed,
449464
format_bytes(index_size),
450465
model_name,
466+
intelligence,
451467
));
452468
out
453469
}
@@ -558,7 +574,7 @@ mod tests {
558574
wikilink_count: None,
559575
mention_count: None,
560576
};
561-
let output = format_status(&stats, 2_516_582, "all-MiniLM-L6-v2", false);
577+
let output = format_status(&stats, 2_516_582, "all-MiniLM-L6-v2", "disabled", false);
562578

563579
assert!(output.contains("/path/to/vault"), "missing vault path");
564580
assert!(output.contains("42"), "missing file count");
@@ -567,6 +583,7 @@ mod tests {
567583
assert!(output.contains("2026-03-19 14:30:00"), "missing last index");
568584
assert!(output.contains("2.4 MB"), "missing index size");
569585
assert!(output.contains("all-MiniLM-L6-v2"), "missing model");
586+
assert!(output.contains("disabled"), "missing intelligence");
570587
}
571588

572589
#[test]
@@ -581,7 +598,7 @@ mod tests {
581598
wikilink_count: None,
582599
mention_count: None,
583600
};
584-
let output = format_status(&stats, 2_516_582, "all-MiniLM-L6-v2", true);
601+
let output = format_status(&stats, 2_516_582, "all-MiniLM-L6-v2", "enabled", true);
585602
let parsed: serde_json::Value = serde_json::from_str(&output).unwrap();
586603

587604
assert_eq!(parsed["vault"], "/path/to/vault");
@@ -591,6 +608,7 @@ mod tests {
591608
assert_eq!(parsed["last_indexed"], "2026-03-19 14:30:00");
592609
assert_eq!(parsed["index_size"], 2_516_582);
593610
assert_eq!(parsed["model"], "all-MiniLM-L6-v2");
611+
assert_eq!(parsed["intelligence"], "enabled");
594612
}
595613

596614
#[test]

0 commit comments

Comments
 (0)