Skip to content

Commit 967890e

Browse files
committed
Colorize CLI markdown output
1 parent 4844d2c commit 967890e

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

bin/chat.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const colors = {
1818
user: '\x1b[33m', // yellow
1919
tool: '\x1b[90m', // gray
2020
error: '\x1b[31m', // red
21+
code: '\x1b[94m', // light blue
2122
normal: '\x1b[0m', // reset
2223
}
2324

@@ -202,15 +203,36 @@ function write(...args) {
202203

203204
/**
204205
* Handle streaming output, but buffer if needed to handle escape codes.
206+
* Also renders inline code (backticks) in blue.
205207
* @returns {(...args: string[]) => void}
206208
*/
207209
function writeWithColor() {
208210
/** @type {string | undefined} */
209211
let buffer
212+
/** @type {string | undefined} */
213+
let codeBuffer
210214
/**
211215
* @param {string} char
212216
*/
213217
function writeChar(char) {
218+
// Handle inline code blocks (backticks)
219+
if (char === '`') {
220+
if (codeBuffer !== undefined) {
221+
// Closing backtick - output buffered content in blue
222+
write(colors.code, codeBuffer, colors.normal)
223+
codeBuffer = undefined
224+
} else {
225+
// Opening backtick - start buffering
226+
codeBuffer = ''
227+
}
228+
return
229+
}
230+
if (codeBuffer !== undefined) {
231+
// Inside inline code block - buffer the character
232+
codeBuffer += char
233+
return
234+
}
235+
214236
if (buffer === undefined && char !== '\\' && char !== '\x1b') {
215237
write(char)
216238
} else {

bin/tools/parquetSql.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const maxRows = 100
1111
* @type {ToolHandler}
1212
*/
1313
export const parquetSql = {
14-
emoji: '🗃️',
14+
emoji: '🛢️',
1515
tool: {
1616
type: 'function',
1717
name: 'parquet_sql',

0 commit comments

Comments
 (0)