Refactor claudeMessages

This commit is contained in:
Saoud Rizwan
2024-10-06 05:06:19 -04:00
parent 7612e50a5f
commit 09001fa72a
7 changed files with 86 additions and 124 deletions

View File

@@ -1,18 +1,18 @@
import { ClineMessage } from "./ExtensionMessage"
/**
* Combines sequences of command and command_output messages in an array of ClaudeMessages.
* Combines sequences of command and command_output messages in an array of ClineMessages.
*
* This function processes an array of ClaudeMessage objects, looking for sequences
* This function processes an array of ClineMessages objects, looking for sequences
* where a 'command' message is followed by one or more 'command_output' messages.
* When such a sequence is found, it combines them into a single message, merging
* their text contents.
*
* @param messages - An array of ClaudeMessage objects to process.
* @returns A new array of ClaudeMessage objects with command sequences combined.
* @param messages - An array of ClineMessage objects to process.
* @returns A new array of ClineMessage objects with command sequences combined.
*
* @example
* const messages: ClaudeMessage[] = [
* const messages: ClineMessage[] = [
* { type: 'ask', ask: 'command', text: 'ls', ts: 1625097600000 },
* { type: 'ask', ask: 'command_output', text: 'file1.txt', ts: 1625097601000 },
* { type: 'ask', ask: 'command_output', text: 'file2.txt', ts: 1625097602000 }