Apply cargo fmt formatting fixes
This commit is contained in:
+16
-11
@@ -467,11 +467,14 @@ fn build_chat_messages(
|
||||
tool_use_id,
|
||||
content,
|
||||
} => {
|
||||
tool_results.push((tool_use_id.clone(), json!({
|
||||
"role": "tool",
|
||||
"tool_call_id": tool_use_id,
|
||||
"content": content,
|
||||
})));
|
||||
tool_results.push((
|
||||
tool_use_id.clone(),
|
||||
json!({
|
||||
"role": "tool",
|
||||
"tool_call_id": tool_use_id,
|
||||
"content": content,
|
||||
}),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -853,9 +856,10 @@ mod tests {
|
||||
}];
|
||||
|
||||
let out = build_chat_messages(None, &messages, "deepseek-chat");
|
||||
assert!(!out.iter().any(|value| {
|
||||
value.get("role").and_then(Value::as_str) == Some("tool")
|
||||
}));
|
||||
assert!(
|
||||
!out.iter()
|
||||
.any(|value| { value.get("role").and_then(Value::as_str) == Some("tool") })
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -879,9 +883,10 @@ mod tests {
|
||||
];
|
||||
|
||||
let out = build_chat_messages(None, &messages, "deepseek-chat");
|
||||
assert!(out.iter().any(|value| {
|
||||
value.get("role").and_then(Value::as_str) == Some("tool")
|
||||
}));
|
||||
assert!(
|
||||
out.iter()
|
||||
.any(|value| { value.get("role").and_then(Value::as_str) == Some("tool") })
|
||||
);
|
||||
let assistant = out
|
||||
.iter()
|
||||
.find(|value| value.get("role").and_then(Value::as_str) == Some("assistant"))
|
||||
|
||||
+25
-11
@@ -608,9 +608,8 @@ fn ensure_parent_dir(path: &Path) -> Result<()> {
|
||||
if let Some(parent) = path.parent()
|
||||
&& !parent.as_os_str().is_empty()
|
||||
{
|
||||
std::fs::create_dir_all(parent).with_context(|| {
|
||||
format!("Failed to create directory for {}", parent.display())
|
||||
})?;
|
||||
std::fs::create_dir_all(parent)
|
||||
.with_context(|| format!("Failed to create directory for {}", parent.display()))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -701,9 +700,7 @@ fn run_setup(config: &Config, workspace: &Path, args: SetupArgs) -> Result<()> {
|
||||
|
||||
println!(
|
||||
"{}",
|
||||
"DeepSeek Setup"
|
||||
.truecolor(aqua_r, aqua_g, aqua_b)
|
||||
.bold()
|
||||
"DeepSeek Setup".truecolor(aqua_r, aqua_g, aqua_b).bold()
|
||||
);
|
||||
println!("{}", "==============".truecolor(sky_r, sky_g, sky_b));
|
||||
println!("Workspace: {}", workspace.display());
|
||||
@@ -740,7 +737,10 @@ fn run_setup(config: &Config, workspace: &Path, args: SetupArgs) -> Result<()> {
|
||||
println!(" ✓ Overwrote example skill at {}", skill_path.display());
|
||||
}
|
||||
WriteStatus::SkippedExists => {
|
||||
println!(" · Example skill already exists at {}", skill_path.display());
|
||||
println!(
|
||||
" · Example skill already exists at {}",
|
||||
skill_path.display()
|
||||
);
|
||||
}
|
||||
}
|
||||
if args.local {
|
||||
@@ -795,7 +795,11 @@ async fn run_doctor(config: &Config, workspace: &Path, config_path_override: Opt
|
||||
dirs::home_dir().map_or_else(|| PathBuf::from(".deepseek"), |h| h.join(".deepseek"));
|
||||
let config_path = config_path_override
|
||||
.map(PathBuf::from)
|
||||
.or_else(|| std::env::var("DEEPSEEK_CONFIG_PATH").ok().map(PathBuf::from))
|
||||
.or_else(|| {
|
||||
std::env::var("DEEPSEEK_CONFIG_PATH")
|
||||
.ok()
|
||||
.map(PathBuf::from)
|
||||
})
|
||||
.unwrap_or_else(|| default_config_dir.join("config.toml"));
|
||||
|
||||
if config_path.exists() {
|
||||
@@ -885,9 +889,15 @@ async fn run_doctor(config: &Config, workspace: &Path, config_path_override: Opt
|
||||
println!("{}", "MCP Servers:".bold());
|
||||
let features = config.features();
|
||||
if features.enabled(Feature::Mcp) {
|
||||
println!(" {} MCP feature flag enabled", "✓".truecolor(aqua_r, aqua_g, aqua_b));
|
||||
println!(
|
||||
" {} MCP feature flag enabled",
|
||||
"✓".truecolor(aqua_r, aqua_g, aqua_b)
|
||||
);
|
||||
} else {
|
||||
println!(" {} MCP feature flag disabled", "!".truecolor(sky_r, sky_g, sky_b));
|
||||
println!(
|
||||
" {} MCP feature flag disabled",
|
||||
"!".truecolor(sky_r, sky_g, sky_b)
|
||||
);
|
||||
}
|
||||
|
||||
let mcp_config_path = config.mcp_config_path();
|
||||
@@ -975,7 +985,11 @@ async fn run_doctor(config: &Config, workspace: &Path, config_path_override: Opt
|
||||
);
|
||||
}
|
||||
|
||||
println!(" {} selected skills dir: {}", "·".dimmed(), selected_skills_dir.display());
|
||||
println!(
|
||||
" {} selected skills dir: {}",
|
||||
"·".dimmed(),
|
||||
selected_skills_dir.display()
|
||||
);
|
||||
if !local_skills_dir.exists() && !global_skills_dir.exists() {
|
||||
println!(" Run `deepseek setup --skills` (or add --local for ./skills).");
|
||||
}
|
||||
|
||||
+5
-5
@@ -53,11 +53,11 @@ pub const STATUS_INFO: Color = DEEPSEEK_BLUE;
|
||||
|
||||
// Mode-specific accent colors for mode badges
|
||||
pub const MODE_NORMAL: Color = Color::Gray;
|
||||
pub const MODE_AGENT: Color = Color::Rgb(80, 150, 255); // Bright blue
|
||||
pub const MODE_YOLO: Color = Color::Rgb(255, 100, 100); // Warning red
|
||||
pub const MODE_PLAN: Color = Color::Rgb(255, 170, 60); // Orange
|
||||
pub const MODE_RLM: Color = Color::Rgb(180, 100, 255); // Purple (was INK!)
|
||||
pub const MODE_DUO: Color = Color::Rgb(100, 220, 180); // Teal
|
||||
pub const MODE_AGENT: Color = Color::Rgb(80, 150, 255); // Bright blue
|
||||
pub const MODE_YOLO: Color = Color::Rgb(255, 100, 100); // Warning red
|
||||
pub const MODE_PLAN: Color = Color::Rgb(255, 170, 60); // Orange
|
||||
pub const MODE_RLM: Color = Color::Rgb(180, 100, 255); // Purple (was INK!)
|
||||
pub const MODE_DUO: Color = Color::Rgb(100, 220, 180); // Teal
|
||||
|
||||
pub const SELECTION_BG: Color = Color::Rgb(26, 44, 74);
|
||||
pub const COMPOSER_BG: Color = DEEPSEEK_SLATE;
|
||||
|
||||
+1
-4
@@ -634,10 +634,7 @@ fn validate_swarm_tasks(tasks: &[SwarmTaskSpec]) -> Result<(), ToolError> {
|
||||
)));
|
||||
}
|
||||
if matches!(task.agent_type, Some(SubAgentType::Custom)) {
|
||||
let tools = task
|
||||
.allowed_tools
|
||||
.as_deref()
|
||||
.unwrap_or(&[]);
|
||||
let tools = task.allowed_tools.as_deref().unwrap_or(&[]);
|
||||
if tools.is_empty() {
|
||||
return Err(ToolError::invalid_input(format!(
|
||||
"task '{id}' requires allowed_tools for custom type"
|
||||
|
||||
+27
-29
@@ -2085,27 +2085,27 @@ fn render_status_indicator(f: &mut Frame, area: Rect, app: &App, queued: &[Strin
|
||||
fn render_footer(f: &mut Frame, area: Rect, app: &App) {
|
||||
let width = area.width;
|
||||
let available = width as usize;
|
||||
|
||||
|
||||
// Build left side: [MODE] context_bar
|
||||
let context_text = context_indicator(app);
|
||||
let mode_badge = Span::styled(
|
||||
format!(" {} ", app.mode.label()),
|
||||
mode_badge_style(app.mode),
|
||||
);
|
||||
|
||||
|
||||
let context_info = Span::styled(
|
||||
context_text.clone(),
|
||||
Style::default().fg(palette::TEXT_MUTED),
|
||||
);
|
||||
|
||||
|
||||
// Calculate widths for left side
|
||||
let mode_width = mode_badge.content.width();
|
||||
let context_width = context_text.width();
|
||||
let left_min_width = mode_width + 1 + context_width; // mode + space + context
|
||||
|
||||
|
||||
// Build right side: key hints and other info
|
||||
let mut right_spans = Vec::new();
|
||||
|
||||
|
||||
// Add scroll info if applicable
|
||||
let can_scroll = app.last_transcript_total > app.last_transcript_visible;
|
||||
if can_scroll && !matches!(app.transcript_scroll, TranscriptScroll::ToBottom) {
|
||||
@@ -2114,7 +2114,7 @@ fn render_footer(f: &mut Frame, area: Rect, app: &App) {
|
||||
Style::default().fg(palette::TEXT_DIM),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
// Add selection hint if active
|
||||
if app.transcript_selection.is_active() {
|
||||
right_spans.push(Span::styled(
|
||||
@@ -2128,26 +2128,21 @@ fn render_footer(f: &mut Frame, area: Rect, app: &App) {
|
||||
if app.mode == AppMode::Rlm {
|
||||
if let Some((badge, style)) = rlm_usage_badge(app) {
|
||||
right_spans.push(Span::styled(badge, style));
|
||||
right_spans.push(Span::styled(
|
||||
" · ",
|
||||
Style::default().fg(palette::TEXT_DIM),
|
||||
));
|
||||
right_spans.push(Span::styled(" · ", Style::default().fg(palette::TEXT_DIM)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add key hints
|
||||
right_spans.extend(footer_key_hints(width, app));
|
||||
|
||||
|
||||
// Calculate right side width
|
||||
let spans_width = |spans: &[Span]| -> usize {
|
||||
spans.iter().map(|s| s.content.width()).sum()
|
||||
};
|
||||
let spans_width = |spans: &[Span]| -> usize { spans.iter().map(|s| s.content.width()).sum() };
|
||||
let mut right_width = spans_width(&right_spans);
|
||||
|
||||
|
||||
// Determine layout based on available space
|
||||
let left_spans: Vec<Span>;
|
||||
let left_width: usize;
|
||||
|
||||
|
||||
if width >= 80 {
|
||||
// Wide: show full context bar
|
||||
left_spans = vec![mode_badge, Span::raw(" "), context_info];
|
||||
@@ -2157,10 +2152,11 @@ fn render_footer(f: &mut Frame, area: Rect, app: &App) {
|
||||
let percent = get_context_percent(app);
|
||||
let short_context = format!("{}%", percent);
|
||||
let short_width = mode_width + 1 + short_context.width();
|
||||
left_spans = vec![mode_badge, Span::raw(" "), Span::styled(
|
||||
short_context,
|
||||
Style::default().fg(palette::TEXT_MUTED),
|
||||
)];
|
||||
left_spans = vec![
|
||||
mode_badge,
|
||||
Span::raw(" "),
|
||||
Span::styled(short_context, Style::default().fg(palette::TEXT_MUTED)),
|
||||
];
|
||||
left_width = short_width;
|
||||
} else {
|
||||
// Narrow: just mode badge
|
||||
@@ -2187,24 +2183,24 @@ fn render_footer(f: &mut Frame, area: Rect, app: &App) {
|
||||
}
|
||||
}
|
||||
let mid_spacing = available.saturating_sub(left_width + right_width);
|
||||
|
||||
|
||||
// Combine all spans
|
||||
let mut all_spans = left_spans;
|
||||
|
||||
|
||||
// Add spacing between left and right
|
||||
if mid_spacing > 0 {
|
||||
all_spans.push(Span::raw(" ".repeat(mid_spacing)));
|
||||
}
|
||||
|
||||
|
||||
// Add right side spans
|
||||
all_spans.extend(right_spans);
|
||||
|
||||
|
||||
// Add status message if present (replaces everything)
|
||||
if let Some(ref msg) = app.status_message {
|
||||
let status_span = Span::styled(msg, Style::default().fg(palette::DEEPSEEK_SKY));
|
||||
all_spans = vec![status_span];
|
||||
}
|
||||
|
||||
|
||||
let footer = Paragraph::new(Line::from(all_spans));
|
||||
f.render_widget(footer, area);
|
||||
}
|
||||
@@ -2216,12 +2212,13 @@ fn get_context_percent(app: &App) -> u8 {
|
||||
} else {
|
||||
estimated_context_tokens(app)
|
||||
};
|
||||
|
||||
|
||||
if let Some(max) = context_window_for_model(&app.model) {
|
||||
if let Some(used) = used {
|
||||
let max_i64 = i64::from(max);
|
||||
let remaining = (max_i64 - used).max(0);
|
||||
let percent_remaining = ((remaining.saturating_mul(100) + max_i64 / 2) / max_i64).clamp(0, 100);
|
||||
let percent_remaining =
|
||||
((remaining.saturating_mul(100) + max_i64 / 2) / max_i64).clamp(0, 100);
|
||||
100 - percent_remaining as u8
|
||||
} else {
|
||||
0
|
||||
@@ -2350,7 +2347,8 @@ fn context_indicator(app: &App) -> String {
|
||||
if let Some(used) = used {
|
||||
let max_i64 = i64::from(max);
|
||||
let remaining = (max_i64 - used).max(0);
|
||||
let percent_remaining = ((remaining.saturating_mul(100) + max_i64 / 2) / max_i64).clamp(0, 100);
|
||||
let percent_remaining =
|
||||
((remaining.saturating_mul(100) + max_i64 / 2) / max_i64).clamp(0, 100);
|
||||
let percent_used = (100 - percent_remaining) as u8;
|
||||
render_context_bar(percent_used, 10)
|
||||
} else {
|
||||
|
||||
@@ -81,9 +81,7 @@ impl<'a> HeaderWidget<'a> {
|
||||
let color = Self::mode_color(self.data.mode);
|
||||
Span::styled(
|
||||
format!("[{label}]"),
|
||||
Style::default()
|
||||
.fg(color)
|
||||
.add_modifier(Modifier::BOLD),
|
||||
Style::default().fg(color).add_modifier(Modifier::BOLD),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -191,7 +189,10 @@ impl Renderable for HeaderWidget<'_> {
|
||||
} else {
|
||||
model_str.to_string()
|
||||
};
|
||||
spans.push(Span::styled(display_model, Style::default().fg(palette::TEXT_MUTED)));
|
||||
spans.push(Span::styled(
|
||||
display_model,
|
||||
Style::default().fg(palette::TEXT_MUTED),
|
||||
));
|
||||
} else if available >= mode_width {
|
||||
// Minimal: just mode badge
|
||||
spans.push(mode_span);
|
||||
|
||||
+1
-3
@@ -389,9 +389,7 @@ fn clean_relative(path: &Path) -> PathBuf {
|
||||
}
|
||||
|
||||
fn path_to_string(path: &Path) -> Option<String> {
|
||||
path.as_os_str()
|
||||
.to_str()
|
||||
.map(|s| s.replace('\\', "/"))
|
||||
path.as_os_str().to_str().map(|s| s.replace('\\', "/"))
|
||||
}
|
||||
|
||||
fn extract_paths_from_message(message: &Message) -> Vec<String> {
|
||||
|
||||
Reference in New Issue
Block a user