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

Function processBashContext

cli/src/utils/bash-context-processor.ts:11–47  ·  view source on GitHub ↗
(
  pendingBashMessages: PendingBashMessage[],
)

Source from the content-addressed store, hash-verified

9
10// Turns pending bash executions into chat history messages and prompt context.
11export const processBashContext = (
12 pendingBashMessages: PendingBashMessage[],
13): {
14 bashMessages: ChatMessage[]
15 bashContextForPrompt: string
16} => {
17 const bashContextForPrompt = formatBashContextForPrompt(pendingBashMessages)
18 const bashMessages: ChatMessage[] = []
19
20 for (const bash of pendingBashMessages) {
21 if (bash.addedToHistory) {
22 continue
23 }
24
25 const toolCallId = crypto.randomUUID()
26 const cwd = bash.cwd || process.cwd()
27 const toolResultOutput = createRunTerminalToolResult({
28 command: bash.command,
29 cwd,
30 stdout: bash.stdout || null,
31 stderr: bash.stderr || null,
32 exitCode: bash.exitCode,
33 })
34 const outputJson = JSON.stringify(toolResultOutput)
35 const { assistantMessage } = buildBashHistoryMessages({
36 command: bash.command,
37 cwd,
38 toolCallId,
39 output: outputJson,
40 isComplete: true,
41 })
42
43 bashMessages.push(assistantMessage)
44 }
45
46 return { bashMessages, bashContextForPrompt }
47}

Callers 2

prepareUserMessageFunction · 0.90

Calls 3

buildBashHistoryMessagesFunction · 0.90

Tested by

no test coverage detected