@@ -73,65 +73,13 @@ use hooks::{
7373 Hook ,
7474 HookTrigger ,
7575} ;
76+ use input_source:: InputSource ;
7677use message:: {
7778 AssistantMessage ,
7879 AssistantToolUse ,
7980 ToolUseResult ,
8081 ToolUseResultBlock ,
8182} ;
82- use rand:: distr:: {
83- Alphanumeric ,
84- SampleString ,
85- } ;
86- use tokio:: signal:: ctrl_c;
87- use util:: shared_writer:: {
88- NullWriter ,
89- SharedWriter ,
90- } ;
91- use util:: ui:: draw_box;
92-
93- use crate :: api_client:: StreamingClient ;
94- use crate :: api_client:: clients:: SendMessageOutput ;
95- use crate :: api_client:: model:: {
96- ChatResponseStream ,
97- Tool as FigTool ,
98- ToolResultStatus ,
99- } ;
100- use crate :: database:: Database ;
101- use crate :: database:: settings:: Setting ;
102- use crate :: platform:: Context ;
103- use crate :: telemetry:: TelemetryThread ;
104- use crate :: telemetry:: core:: ToolUseEventBuilder ;
105-
106- /// Help text for the compact command
107- fn compact_help_text ( ) -> String {
108- color_print:: cformat!(
109- r#"
110- <magenta,em>Conversation Compaction</magenta,em>
111-
112- The <em>/compact</em> command summarizes the conversation history to free up context space
113- while preserving essential information. This is useful for long-running conversations
114- that may eventually reach memory constraints.
115-
116- <cyan!>Usage</cyan!>
117- <em>/compact</em> <black!>Summarize the conversation and clear history</black!>
118- <em>/compact [prompt]</em> <black!>Provide custom guidance for summarization</black!>
119-
120- <cyan!>When to use</cyan!>
121- • When you see the memory constraint warning message
122- • When a conversation has been running for a long time
123- • Before starting a new topic within the same session
124- • After completing complex tool operations
125-
126- <cyan!>How it works</cyan!>
127- • Creates an AI-generated summary of your conversation
128- • Retains key information, code, and tool executions in the summary
129- • Clears the conversation history to free up space
130- • The assistant will reference the summary context in future responses
131- "#
132- )
133- }
134- use input_source:: InputSource ;
13583use parse:: {
13684 ParseState ,
13785 interpret_markdown,
@@ -140,6 +88,10 @@ use parser::{
14088 RecvErrorKind ,
14189 ResponseParser ,
14290} ;
91+ use rand:: distr:: {
92+ Alphanumeric ,
93+ SampleString ,
94+ } ;
14395use regex:: Regex ;
14496use serde_json:: Map ;
14597use spinners:: {
@@ -151,6 +103,7 @@ use token_counter::{
151103 TokenCount ,
152104 TokenCounter ,
153105} ;
106+ use tokio:: signal:: ctrl_c;
154107use tool_manager:: {
155108 GetPromptError ,
156109 McpServerConfig ,
@@ -175,6 +128,11 @@ use tracing::{
175128} ;
176129use unicode_width:: UnicodeWidthStr ;
177130use util:: images:: RichImageBlock ;
131+ use util:: shared_writer:: {
132+ NullWriter ,
133+ SharedWriter ,
134+ } ;
135+ use util:: ui:: draw_box;
178136use util:: {
179137 animate_output,
180138 drop_matched_context_files,
@@ -185,10 +143,52 @@ use uuid::Uuid;
185143use winnow:: Partial ;
186144use winnow:: stream:: Offset ;
187145
146+ use crate :: api_client:: StreamingClient ;
147+ use crate :: api_client:: clients:: SendMessageOutput ;
148+ use crate :: api_client:: model:: {
149+ ChatResponseStream ,
150+ Tool as FigTool ,
151+ ToolResultStatus ,
152+ } ;
153+ use crate :: database:: Database ;
154+ use crate :: database:: settings:: Setting ;
188155use crate :: mcp_client:: {
189156 Prompt ,
190157 PromptGetResult ,
191158} ;
159+ use crate :: platform:: Context ;
160+ use crate :: telemetry:: TelemetryThread ;
161+ use crate :: telemetry:: core:: ToolUseEventBuilder ;
162+ use crate :: util:: CHAT_BINARY_NAME ;
163+
164+ /// Help text for the compact command
165+ fn compact_help_text ( ) -> String {
166+ color_print:: cformat!(
167+ r#"
168+ <magenta,em>Conversation Compaction</magenta,em>
169+
170+ The <em>/compact</em> command summarizes the conversation history to free up context space
171+ while preserving essential information. This is useful for long-running conversations
172+ that may eventually reach memory constraints.
173+
174+ <cyan!>Usage</cyan!>
175+ <em>/compact</em> <black!>Summarize the conversation and clear history</black!>
176+ <em>/compact [prompt]</em> <black!>Provide custom guidance for summarization</black!>
177+
178+ <cyan!>When to use</cyan!>
179+ • When you see the memory constraint warning message
180+ • When a conversation has been running for a long time
181+ • Before starting a new topic within the same session
182+ • After completing complex tool operations
183+
184+ <cyan!>How it works</cyan!>
185+ • Creates an AI-generated summary of your conversation
186+ • Retains key information, code, and tool executions in the summary
187+ • Clears the conversation history to free up space
188+ • The assistant will reference the summary context in future responses
189+ "#
190+ )
191+ }
192192
193193const WELCOME_TEXT : & str = color_print:: cstr! { "<cyan!>
194194 ⢠⣶⣶⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣶⣿⣿⣿⣶⣦⡀⠀
@@ -317,7 +317,10 @@ pub async fn chat(
317317 trust_tools : Option < Vec < String > > ,
318318) -> Result < ExitCode > {
319319 if !crate :: util:: system_info:: in_cloudshell ( ) && !crate :: auth:: is_logged_in ( database) . await {
320- bail ! ( "You are not logged in, please log in with {}" , "q login" . bold( ) ) ;
320+ bail ! (
321+ "You are not logged in, please log in with {}" ,
322+ format!( "{CHAT_BINARY_NAME} login" ) . bold( )
323+ ) ;
321324 }
322325
323326 region_check ( "chat" ) ?;
0 commit comments