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

Function formatBashContextForPrompt

cli/src/utils/bash-messages.ts:77–108  ·  view source on GitHub ↗
(
  pendingBashMessages: PendingBashMessage[],
)

Source from the content-addressed store, hash-verified

75 * Only includes completed (non-running) commands.
76 */
77export function formatBashContextForPrompt(
78 pendingBashMessages: PendingBashMessage[],
79): string {
80 // Only include completed commands
81 const completedCommands = pendingBashMessages.filter((msg) => !msg.isRunning)
82
83 if (completedCommands.length === 0) {
84 return ''
85 }
86
87 const commandsContext = completedCommands
88 .map((bash) => {
89 const cwd = bash.cwd || process.cwd()
90 let result = `Command: ${bash.command}\nDirectory: ${cwd}\nExit code: ${bash.exitCode}`
91 if (bash.stdout) {
92 result += `\nStdout:\n${bash.stdout}`
93 }
94 if (bash.stderr) {
95 result += `\nStderr:\n${bash.stderr}`
96 }
97 return result
98 })
99 .join('\n\n---\n\n')
100
101 return `<user_terminal_commands>
102The user ran the following terminal command(s) before this message:
103
104${commandsContext}
105</user_terminal_commands>
106
107`
108}

Callers 1

processBashContextFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected