MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / buildBashHistoryMessages

Function buildBashHistoryMessages

cli/src/utils/bash-messages.ts:38–70  ·  view source on GitHub ↗
(params: {
  command: string
  cwd: string
  toolCallId?: string
  output?: string
  isComplete?: boolean
})

Source from the content-addressed store, hash-verified

36}
37
38export function buildBashHistoryMessages(params: {
39 command: string
40 cwd: string
41 toolCallId?: string
42 output?: string
43 isComplete?: boolean
44}): {
45 assistantMessage: ChatMessage
46 toolCallId: string
47} {
48 const { command, cwd, output = '...', isComplete = false } = params
49 const toolCallId = params.toolCallId ?? crypto.randomUUID()
50
51 const toolBlock: ContentBlock = {
52 type: 'tool',
53 toolName: 'run_terminal_command',
54 toolCallId,
55 input: { command },
56 output,
57 }
58
59 const assistantMessage: ChatMessage = {
60 id: `bash-result-${toolCallId}`,
61 variant: 'ai',
62 content: '',
63 blocks: [toolBlock],
64 timestamp: formatTimestamp(),
65 isComplete,
66 metadata: { bashCwd: cwd },
67 }
68
69 return { assistantMessage, toolCallId }
70}
71
72/**
73 * Format pending bash messages as context to prepend to the user's prompt.

Callers 3

processBashContextFunction · 0.90
runBashCommandFunction · 0.90
addBashMessageToHistoryFunction · 0.90

Calls 1

formatTimestampFunction · 0.90

Tested by

no test coverage detected