diff --git a/Cargo.lock b/Cargo.lock index a11c7c2259..2e6dc2da28 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1521,7 +1521,6 @@ dependencies = [ "bytes", "camino", "cfg-if", - "chrono", "clap", "clap_complete", "clap_complete_fig", diff --git a/crates/chat-cli/Cargo.toml b/crates/chat-cli/Cargo.toml index 10ed45d145..2b7ae4d42b 100644 --- a/crates/chat-cli/Cargo.toml +++ b/crates/chat-cli/Cargo.toml @@ -45,7 +45,6 @@ bstr = "1.12.0" bytes = "1.10.1" camino = { version = "1.1.3", features = ["serde1"] } cfg-if = "1.0.0" -chrono = { version = "0.4.41", default-features = false, features = ["std"] } clap = { version = "4.5.32", features = [ "deprecated", "derive", diff --git a/crates/chat-cli/src/cli/chat/conversation_state.rs b/crates/chat-cli/src/cli/chat/conversation_state.rs index 6d5aae8fb1..da0c5941dd 100644 --- a/crates/chat-cli/src/cli/chat/conversation_state.rs +++ b/crates/chat-cli/src/cli/chat/conversation_state.rs @@ -220,9 +220,7 @@ impl ConversationState { warn!("input must not be empty when adding new messages"); "Empty prompt".to_string() } else { - let now = chrono::Utc::now(); - let formatted_time = now.format("%Y-%m-%d %H:%M:%S").to_string(); - format!("{}\n\n\n{}\n", input, formatted_time) + input }; let msg = UserMessage::new_prompt(input); diff --git a/crates/chat-cli/src/cli/chat/mod.rs b/crates/chat-cli/src/cli/chat/mod.rs index 520bb4795c..d547d6ced8 100644 --- a/crates/chat-cli/src/cli/chat/mod.rs +++ b/crates/chat-cli/src/cli/chat/mod.rs @@ -73,65 +73,13 @@ use hooks::{ Hook, HookTrigger, }; +use input_source::InputSource; use message::{ AssistantMessage, AssistantToolUse, ToolUseResult, ToolUseResultBlock, }; -use rand::distr::{ - Alphanumeric, - SampleString, -}; -use tokio::signal::ctrl_c; -use util::shared_writer::{ - NullWriter, - SharedWriter, -}; -use util::ui::draw_box; - -use crate::api_client::StreamingClient; -use crate::api_client::clients::SendMessageOutput; -use crate::api_client::model::{ - ChatResponseStream, - Tool as FigTool, - ToolResultStatus, -}; -use crate::database::Database; -use crate::database::settings::Setting; -use crate::platform::Context; -use crate::telemetry::TelemetryThread; -use crate::telemetry::core::ToolUseEventBuilder; - -/// Help text for the compact command -fn compact_help_text() -> String { - color_print::cformat!( - r#" -Conversation Compaction - -The /compact command summarizes the conversation history to free up context space -while preserving essential information. This is useful for long-running conversations -that may eventually reach memory constraints. - -Usage - /compact Summarize the conversation and clear history - /compact [prompt] Provide custom guidance for summarization - -When to use -• When you see the memory constraint warning message -• When a conversation has been running for a long time -• Before starting a new topic within the same session -• After completing complex tool operations - -How it works -• Creates an AI-generated summary of your conversation -• Retains key information, code, and tool executions in the summary -• Clears the conversation history to free up space -• The assistant will reference the summary context in future responses -"# - ) -} -use input_source::InputSource; use parse::{ ParseState, interpret_markdown, @@ -140,6 +88,10 @@ use parser::{ RecvErrorKind, ResponseParser, }; +use rand::distr::{ + Alphanumeric, + SampleString, +}; use regex::Regex; use serde_json::Map; use spinners::{ @@ -151,6 +103,7 @@ use token_counter::{ TokenCount, TokenCounter, }; +use tokio::signal::ctrl_c; use tool_manager::{ GetPromptError, McpServerConfig, @@ -175,6 +128,11 @@ use tracing::{ }; use unicode_width::UnicodeWidthStr; use util::images::RichImageBlock; +use util::shared_writer::{ + NullWriter, + SharedWriter, +}; +use util::ui::draw_box; use util::{ animate_output, drop_matched_context_files, @@ -185,10 +143,52 @@ use uuid::Uuid; use winnow::Partial; use winnow::stream::Offset; +use crate::api_client::StreamingClient; +use crate::api_client::clients::SendMessageOutput; +use crate::api_client::model::{ + ChatResponseStream, + Tool as FigTool, + ToolResultStatus, +}; +use crate::database::Database; +use crate::database::settings::Setting; use crate::mcp_client::{ Prompt, PromptGetResult, }; +use crate::platform::Context; +use crate::telemetry::TelemetryThread; +use crate::telemetry::core::ToolUseEventBuilder; +use crate::util::CHAT_BINARY_NAME; + +/// Help text for the compact command +fn compact_help_text() -> String { + color_print::cformat!( + r#" +Conversation Compaction + +The /compact command summarizes the conversation history to free up context space +while preserving essential information. This is useful for long-running conversations +that may eventually reach memory constraints. + +Usage + /compact Summarize the conversation and clear history + /compact [prompt] Provide custom guidance for summarization + +When to use +• When you see the memory constraint warning message +• When a conversation has been running for a long time +• Before starting a new topic within the same session +• After completing complex tool operations + +How it works +• Creates an AI-generated summary of your conversation +• Retains key information, code, and tool executions in the summary +• Clears the conversation history to free up space +• The assistant will reference the summary context in future responses +"# + ) +} const WELCOME_TEXT: &str = color_print::cstr! {" ⢠⣶⣶⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣶⣿⣿⣿⣶⣦⡀⠀ @@ -317,7 +317,10 @@ pub async fn chat( trust_tools: Option>, ) -> Result { if !crate::util::system_info::in_cloudshell() && !crate::auth::is_logged_in(database).await { - bail!("You are not logged in, please log in with {}", "q login".bold()); + bail!( + "You are not logged in, please log in with {}", + format!("{CHAT_BINARY_NAME} login").bold() + ); } region_check("chat")?; diff --git a/crates/chat-cli/src/cli/user.rs b/crates/chat-cli/src/cli/user.rs index a661491708..07cdacf10b 100644 --- a/crates/chat-cli/src/cli/user.rs +++ b/crates/chat-cli/src/cli/user.rs @@ -187,7 +187,10 @@ impl UserSubcommand { }, Self::Profile => { if !crate::util::system_info::in_cloudshell() && !crate::auth::is_logged_in(database).await { - bail!("You are not logged in, please log in with {}", "q login".bold()); + bail!( + "You are not logged in, please log in with {}", + format!("{CHAT_BINARY_NAME} login").bold() + ); } if let Ok(Some(token)) = BuilderIdToken::load(database).await {