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

Function truncateToSingleLinePreview

cli/src/utils/agent-display.ts:12–27  ·  view source on GitHub ↗
(
  text: string,
  maxLength = DEFAULT_BASHER_OUTPUT_PREVIEW_MAX_LENGTH,
)

Source from the content-addressed store, hash-verified

10const PREVIEW_ELLIPSIS = '...'
11
12export function truncateToSingleLinePreview(
13 text: string,
14 maxLength = DEFAULT_BASHER_OUTPUT_PREVIEW_MAX_LENGTH,
15): string | undefined {
16 const singleLine = text.replace(/\s+/g, ' ').trim()
17 if (!singleLine) {
18 return undefined
19 }
20
21 if (singleLine.length <= maxLength) {
22 return singleLine
23 }
24
25 const previewLength = Math.max(0, maxLength - PREVIEW_ELLIPSIS.length)
26 return `${singleLine.slice(0, previewLength).trimEnd()}${PREVIEW_ELLIPSIS}`
27}
28
29export function getAgentDisplayPrompt(
30 agentBlock: AgentContentBlock,

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected