@@ -2261,9 +2261,11 @@ func (r *REPL) getCurrentModelForProvider() string {
22612261
22622262// handleCompactCommand processes the /compact command
22632263// It loads the compact.txt prompt and submits the entire conversation history
2264- // to the AI, then replaces all messages with the AI's response
2264+ // to the AI, then replaces all messages with the AI's response.
2265+ // The optional extra argument is appended to the compact prompt to let the
2266+ // caller steer the summarization (e.g. "focus on the API changes").
22652267
2266- func (r * REPL ) handleCompactCommand () error {
2268+ func (r * REPL ) handleCompactCommand (extra ... string ) error {
22672269 // Check if there are enough messages to compact
22682270 if len (r .messages ) < 2 {
22692271 fmt .Print ("Not enough messages to compact. Need at least one exchange.\r \n " )
@@ -2282,6 +2284,11 @@ func (r *REPL) handleCompactCommand() error {
22822284 return fmt .Errorf ("failed to read compact prompt: %v" , err )
22832285 }
22842286
2287+ promptText := string (compactPrompt )
2288+ if extraText := strings .TrimSpace (strings .Join (extra , " " )); extraText != "" {
2289+ promptText = strings .TrimRight (promptText , "\n " ) + "\n \n " + extraText
2290+ }
2291+
22852292 // Create a serialized version of the conversation for the AI
22862293 var conversationText strings.Builder
22872294 conversationText .WriteString ("# Conversation History\n \n " )
@@ -2294,7 +2301,7 @@ func (r *REPL) handleCompactCommand() error {
22942301 // Create a new message with the compact prompt and conversation history
22952302 compactMessage := llm.Message {
22962303 Role : "user" ,
2297- Content : string ( compactPrompt ) + "\n \n " + conversationText .String (),
2304+ Content : promptText + "\n \n " + conversationText .String (),
22982305 }
22992306
23002307 // Save original messages for recovery if needed
0 commit comments