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
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/chat-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 1 addition & 3 deletions crates/chat-cli/src/cli/chat/conversation_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<currentTimeUTC>\n{}\n</currentTimeUTC>", input, formatted_time)
input
};

let msg = UserMessage::new_prompt(input);
Expand Down
111 changes: 57 additions & 54 deletions crates/chat-cli/src/cli/chat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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#"
<magenta,em>Conversation Compaction</magenta,em>

The <em>/compact</em> 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.

<cyan!>Usage</cyan!>
<em>/compact</em> <black!>Summarize the conversation and clear history</black!>
<em>/compact [prompt]</em> <black!>Provide custom guidance for summarization</black!>

<cyan!>When to use</cyan!>
• 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

<cyan!>How it works</cyan!>
• 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,
Expand All @@ -140,6 +88,10 @@ use parser::{
RecvErrorKind,
ResponseParser,
};
use rand::distr::{
Alphanumeric,
SampleString,
};
use regex::Regex;
use serde_json::Map;
use spinners::{
Expand All @@ -151,6 +103,7 @@ use token_counter::{
TokenCount,
TokenCounter,
};
use tokio::signal::ctrl_c;
use tool_manager::{
GetPromptError,
McpServerConfig,
Expand All @@ -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,
Expand All @@ -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#"
<magenta,em>Conversation Compaction</magenta,em>

The <em>/compact</em> 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.

<cyan!>Usage</cyan!>
<em>/compact</em> <black!>Summarize the conversation and clear history</black!>
<em>/compact [prompt]</em> <black!>Provide custom guidance for summarization</black!>

<cyan!>When to use</cyan!>
• 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

<cyan!>How it works</cyan!>
• 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! {"<cyan!>
⢠⣶⣶⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣶⣿⣿⣿⣶⣦⡀⠀
Expand Down Expand Up @@ -317,7 +317,10 @@ pub async fn chat(
trust_tools: Option<Vec<String>>,
) -> Result<ExitCode> {
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")?;
Expand Down
5 changes: 4 additions & 1 deletion crates/chat-cli/src/cli/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading