Skip to content

Commit 9715dac

Browse files
feat: display custom agents in multi-column layout to save vertical space
Format the \"Found custom agents\" list into columns based on terminal width to reduce vertical scrolling and improve readability. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent c71fe13 commit 9715dac

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

npm-app/src/agents/load-agents.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,22 @@ export function displayLoadedAgents(codebuffConfig: CodebuffConfig) {
109109
)
110110
} else if (Object.keys(loadedAgents).length > 0) {
111111
const loadedAgentNames = Object.values(getLoadedAgentNames())
112+
// Calculate terminal width and format agents in columns
113+
const terminalWidth = process.stdout.columns || 80
114+
const columnWidth = Math.max(...loadedAgentNames.map(name => name.length)) + 2 // Column width based on longest name + padding
115+
const columnsPerRow = Math.max(1, Math.floor(terminalWidth / columnWidth))
116+
117+
const formattedLines: string[] = []
118+
for (let i = 0; i < loadedAgentNames.length; i += columnsPerRow) {
119+
const rowAgents = loadedAgentNames.slice(i, i + columnsPerRow)
120+
const formattedRow = rowAgents
121+
.map(name => cyan(name.padEnd(columnWidth)))
122+
.join('')
123+
formattedLines.push(formattedRow)
124+
}
125+
112126
console.log(
113-
`\n${green('Found custom agents:')} ${loadedAgentNames
114-
.map((name) => cyan(name))
115-
.join(', ')}\n`,
127+
`\n${green('Found custom agents:')}\n${formattedLines.join('\n')}\n`,
116128
)
117129
} else if (baseAgent) {
118130
// One more new line.

0 commit comments

Comments
 (0)