Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/chat-cli/src/api_client/delay_interceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ use aws_smithy_types::config_bag::{
Storable,
StoreReplace,
};
use crossterm::style::Color;
use crossterm::{
execute,
style,
};

use crate::api_client::MAX_RETRY_DELAY_DURATION;
use crate::theme::StyledText;

#[derive(Debug, Clone)]
pub struct DelayTrackingInterceptor {
Expand All @@ -39,9 +39,9 @@ impl DelayTrackingInterceptor {
let mut stderr = std::io::stderr();
let _ = execute!(
stderr,
style::SetForegroundColor(Color::Yellow),
StyledText::warning_fg(),
style::Print("\nWARNING: "),
style::SetForegroundColor(Color::Reset),
StyledText::reset(),
style::Print(message),
style::Print("\n")
);
Expand Down
6 changes: 2 additions & 4 deletions crates/chat-cli/src/cli/agent/legacy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use super::{
use crate::cli::agent::hook::Hook;
use crate::cli::agent::legacy::context::LegacyContextConfig;
use crate::os::Os;
use crate::theme::StyledText;
use crate::util::directories;

/// Performs the migration from legacy profile configuration to agent configuration if it hasn't
Expand Down Expand Up @@ -110,10 +111,7 @@ pub async fn migrate(os: &mut Os, force: bool) -> eyre::Result<Option<Vec<Agent>
.interact_on_opt(&dialoguer::console::Term::stdout())
{
Ok(sel) => {
let _ = crossterm::execute!(
std::io::stdout(),
crossterm::style::SetForegroundColor(crossterm::style::Color::Magenta)
);
let _ = crossterm::execute!(std::io::stdout(), StyledText::emphasis_fg());
sel
},
// Ctrl‑C -> Err(Interrupted)
Expand Down
70 changes: 34 additions & 36 deletions crates/chat-cli/src/cli/agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ use std::path::{
PathBuf,
};

use crossterm::style::{
Color,
Stylize as _,
};
use crossterm::style::Stylize as _;
use crossterm::{
execute,
queue,
Expand Down Expand Up @@ -65,6 +62,7 @@ use crate::cli::agent::hook::{
};
use crate::database::settings::Setting;
use crate::os::Os;
use crate::theme::StyledText;
use crate::util::{
self,
MCP_SERVER_TOOL_DELIMITER,
Expand Down Expand Up @@ -232,13 +230,13 @@ impl Agent {
if mcp_servers.mcp_servers.contains_key(name) {
let _ = queue!(
output,
style::SetForegroundColor(Color::Yellow),
StyledText::warning_fg(),
style::Print("WARNING: "),
style::ResetColor,
StyledText::reset(),
style::Print("MCP server '"),
style::SetForegroundColor(Color::Green),
StyledText::success_fg(),
style::Print(name),
style::ResetColor,
StyledText::reset(),
style::Print(
"' is already configured in agent config. Skipping duplicate from legacy mcp.json.\n"
)
Expand Down Expand Up @@ -455,10 +453,10 @@ impl Agents {
if !mcp_enabled {
let _ = execute!(
output,
style::SetForegroundColor(Color::Yellow),
StyledText::warning_fg(),
style::Print("\n"),
style::Print("⚠️ WARNING: "),
style::SetForegroundColor(Color::Reset),
StyledText::reset(),
style::Print("MCP functionality has been disabled by your administrator.\n\n"),
);
}
Expand Down Expand Up @@ -517,9 +515,9 @@ impl Agents {
load_metadata.load_failed_count += 1;
let _ = queue!(
output,
style::SetForegroundColor(Color::Red),
StyledText::error_fg(),
style::Print("Error: "),
style::ResetColor,
StyledText::reset(),
style::Print(e),
style::Print("\n"),
);
Expand Down Expand Up @@ -555,9 +553,9 @@ impl Agents {
load_metadata.load_failed_count += 1;
let _ = queue!(
output,
style::SetForegroundColor(Color::Red),
StyledText::error_fg(),
style::Print("Error: "),
style::ResetColor,
StyledText::reset(),
style::Print(e),
style::Print("\n"),
);
Expand Down Expand Up @@ -625,13 +623,13 @@ impl Agents {
if local_names.contains(name) {
let _ = queue!(
output,
style::SetForegroundColor(style::Color::Yellow),
StyledText::warning_fg(),
style::Print("WARNING: "),
style::ResetColor,
StyledText::reset(),
style::Print("Agent conflict for "),
style::SetForegroundColor(style::Color::Green),
StyledText::success_fg(),
style::Print(name),
style::ResetColor,
StyledText::reset(),
style::Print(". Using workspace version.\n")
);
false
Expand All @@ -655,15 +653,15 @@ impl Agents {
}
let _ = queue!(
output,
style::SetForegroundColor(Color::Red),
StyledText::error_fg(),
style::Print("Error"),
style::SetForegroundColor(Color::Yellow),
StyledText::warning_fg(),
style::Print(format!(
": no agent with name {} found. Falling back to user specified default",
name
)),
style::Print("\n"),
style::SetForegroundColor(Color::Reset)
StyledText::reset(),
);
}

Expand All @@ -673,15 +671,15 @@ impl Agents {
}
let _ = queue!(
output,
style::SetForegroundColor(Color::Red),
StyledText::error_fg(),
style::Print("Error"),
style::SetForegroundColor(Color::Yellow),
StyledText::warning_fg(),
style::Print(format!(
": user defined default {} not found. Falling back to in-memory default",
user_set_default
)),
style::Print("\n"),
style::SetForegroundColor(Color::Reset)
StyledText::reset(),
);
}

Expand Down Expand Up @@ -739,17 +737,17 @@ impl Agents {
let name = &agent.name;
let _ = execute!(
output,
style::SetForegroundColor(Color::Yellow),
StyledText::warning_fg(),
style::Print("WARNING "),
style::ResetColor,
StyledText::reset(),
style::Print("Agent config "),
style::SetForegroundColor(Color::Green),
StyledText::success_fg(),
style::Print(name),
style::ResetColor,
StyledText::reset(),
style::Print(" is malformed at "),
style::SetForegroundColor(Color::Yellow),
StyledText::warning_fg(),
style::Print(&e.instance_path),
style::ResetColor,
StyledText::reset(),
style::Print(format!(": {e}\n")),
);
}
Expand Down Expand Up @@ -892,17 +890,17 @@ pub fn queue_permission_override_warning(
) -> Result<(), std::io::Error> {
Ok(queue!(
output,
style::SetForegroundColor(Color::Yellow),
StyledText::warning_fg(),
style::Print("WARNING: "),
style::ResetColor,
StyledText::reset(),
style::Print("You have trusted "),
style::SetForegroundColor(Color::Green),
StyledText::success_fg(),
style::Print(tool_name),
style::ResetColor,
StyledText::reset(),
style::Print(" tool, which overrides the toolsSettings: "),
style::SetForegroundColor(Color::Cyan),
StyledText::brand_fg(),
style::Print(overridden_settings),
style::ResetColor,
StyledText::reset(),
style::Print("\n"),
)?)
}
Expand Down
54 changes: 27 additions & 27 deletions crates/chat-cli/src/cli/agent/root_command_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use clap::{
Args,
Subcommand,
};
use crossterm::style::Color;
use crossterm::{
queue,
style,
Expand All @@ -25,6 +24,7 @@ use super::{
};
use crate::database::settings::Setting;
use crate::os::Os;
use crate::theme::StyledText;
use crate::util::directories;

#[derive(Clone, Debug, Subcommand, PartialEq, Eq)]
Expand Down Expand Up @@ -175,9 +175,9 @@ impl AgentArgs {
let Ok(instance) = serde_json::to_value(&agent) else {
queue!(
stderr,
style::SetForegroundColor(style::Color::Red),
StyledText::error_fg(),
style::Print("Error: "),
style::ResetColor,
StyledText::reset(),
style::Print("failed to obtain value from agent provided. Aborting validation"),
)?;
break 'validate;
Expand All @@ -188,9 +188,9 @@ impl AgentArgs {
Err(e) => {
queue!(
stderr,
style::SetForegroundColor(style::Color::Red),
StyledText::error_fg(),
style::Print("Error: "),
style::ResetColor,
StyledText::reset(),
style::Print(format!("failed to obtain schema: {e}. Aborting validation"))
)?;
break 'validate;
Expand All @@ -201,27 +201,27 @@ impl AgentArgs {
let name = &agent.name;
queue!(
stderr,
style::SetForegroundColor(Color::Yellow),
StyledText::warning_fg(),
style::Print("WARNING "),
style::ResetColor,
StyledText::reset(),
style::Print("Agent config "),
style::SetForegroundColor(Color::Green),
StyledText::success_fg(),
style::Print(name),
style::ResetColor,
StyledText::reset(),
style::Print(" is malformed at "),
style::SetForegroundColor(Color::Yellow),
StyledText::warning_fg(),
style::Print(&e.instance_path),
style::ResetColor,
StyledText::reset(),
style::Print(format!(": {e}\n")),
)?;
}
},
Err(e) => {
let _ = queue!(
stderr,
style::SetForegroundColor(Color::Red),
StyledText::error_fg(),
style::Print("Error: "),
style::ResetColor,
StyledText::reset(),
style::Print(e),
style::Print("\n"),
);
Expand All @@ -235,15 +235,15 @@ impl AgentArgs {
if !force {
let _ = queue!(
stderr,
style::SetForegroundColor(Color::Yellow),
StyledText::warning_fg(),
style::Print("WARNING: "),
style::ResetColor,
StyledText::reset(),
style::Print(
"manual migrate is potentially destructive to existing agent configs with name collision. Use"
),
style::SetForegroundColor(Color::Cyan),
StyledText::brand_fg(),
style::Print(" --force "),
style::ResetColor,
StyledText::reset(),
style::Print("to run"),
style::Print("\n"),
);
Expand All @@ -255,9 +255,9 @@ impl AgentArgs {
let migrated_count = new_agents.len();
let _ = queue!(
stderr,
style::SetForegroundColor(Color::Green),
StyledText::success_fg(),
style::Print("✓ Success: "),
style::ResetColor,
StyledText::reset(),
style::Print(format!(
"Profile migration successful. Migrated {} agent(s)\n",
migrated_count
Expand All @@ -267,18 +267,18 @@ impl AgentArgs {
Ok(None) => {
let _ = queue!(
stderr,
style::SetForegroundColor(Color::Blue),
StyledText::info_fg(),
style::Print("Info: "),
style::ResetColor,
StyledText::reset(),
style::Print("Migration was not performed. Nothing to migrate\n"),
);
},
Err(e) => {
let _ = queue!(
stderr,
style::SetForegroundColor(Color::Red),
StyledText::error_fg(),
style::Print("Error: "),
style::ResetColor,
StyledText::reset(),
style::Print(format!("Migration did not happen for the following reason: {e}\n")),
);
},
Expand All @@ -295,19 +295,19 @@ impl AgentArgs {

let _ = queue!(
stderr,
style::SetForegroundColor(Color::Green),
StyledText::success_fg(),
style::Print("✓ Default agent set to '"),
style::Print(&agent.name),
style::Print("'. This will take effect the next time q chat is launched.\n"),
style::ResetColor,
StyledText::reset(),
);
},
Err(e) => {
let _ = queue!(
stderr,
style::SetForegroundColor(Color::Red),
StyledText::error_fg(),
style::Print("Error: "),
style::ResetColor,
StyledText::reset(),
style::Print(format!("Failed to set default agent: {e}\n")),
);
},
Expand Down
Loading