MCPcopy Create free account
hub / github.com/GCWing/BitFun / inline_complete_text

Function inline_complete_text

src/apps/cli/src/ui/tool_cards.rs:448–586  ·  view source on GitHub ↗

Generate complete text for inline tools

(canonical: &str, tool_state: &ToolDisplayState)

Source from the content-addressed store, hash-verified

446
447/// Generate complete text for inline tools
448fn inline_complete_text(canonical: &str, tool_state: &ToolDisplayState) -> String {
449 match canonical {
450 "Read" => {
451 let path = param_str(
452 &tool_state.parameters,
453 &["file_path", "target_file", "path"],
454 );
455 format!("Read {}", path)
456 }
457 "Grep" => {
458 let pattern = param_str(&tool_state.parameters, &["pattern"]);
459 let path = param_str_opt(&tool_state.parameters, &["path"]);
460 let count = tool_state
461 .metadata
462 .as_ref()
463 .and_then(|m| m.get("total_matches"))
464 .and_then(|v| v.as_u64())
465 .map(|v| v as usize)
466 .or_else(|| tool_state.result.as_ref().map(|r| r.lines().count()))
467 .unwrap_or(0);
468 let mut text = format!("Grep \"{}\"", pattern);
469 if let Some(p) = path {
470 text.push_str(&format!(" in {}", p));
471 }
472 if count > 0 {
473 text.push_str(&format!(" ({} matches)", count));
474 }
475 text
476 }
477 "Glob" => {
478 let pattern = param_str(
479 &tool_state.parameters,
480 &["glob_pattern", "pattern", "query"],
481 );
482 let count = tool_state
483 .metadata
484 .as_ref()
485 .and_then(|m| m.get("match_count"))
486 .and_then(|v| v.as_u64())
487 .map(|v| v as usize)
488 .or_else(|| tool_state.result.as_ref().map(|r| r.lines().count()))
489 .unwrap_or(0);
490 let mut text = format!("Glob \"{}\"", pattern);
491 if count > 0 {
492 text.push_str(&format!(" ({} matches)", count));
493 }
494 text
495 }
496 "LS" => {
497 let path = param_str(&tool_state.parameters, &["target_directory", "path"]);
498 let count = tool_state
499 .metadata
500 .as_ref()
501 .and_then(|m| m.get("total"))
502 .and_then(|v| v.as_u64())
503 .map(|v| v as usize)
504 .or_else(|| tool_state.result.as_ref().map(|r| r.lines().count()))
505 .unwrap_or(0);

Callers 1

render_inline_dispatchFunction · 0.85

Calls 11

param_strFunction · 0.85
param_str_optFunction · 0.85
extract_key_paramsFunction · 0.85
collectMethod · 0.80
getMethod · 0.45
countMethod · 0.45
push_strMethod · 0.45
is_emptyMethod · 0.45
lenMethod · 0.45
as_strMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected