From 40fbb61a1ba3b0b16c0695c845d986b15768e0af Mon Sep 17 00:00:00 2001 From: Billy Biggs Date: Sun, 15 Jun 2025 23:09:53 -0700 Subject: [PATCH] Update /tools desc to show the name of each tool as known to the model (#1091) --- .../src/ui/hooks/slashCommandProcessor.test.ts | 8 ++++---- .../cli/src/ui/hooks/slashCommandProcessor.ts | 15 ++++----------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts index 2316bc86..d9712d6e 100644 --- a/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts +++ b/packages/cli/src/ui/hooks/slashCommandProcessor.test.ts @@ -606,8 +606,8 @@ Add any other context about the problem here. // Should only show tool1 and tool2, not the MCP tools const message = mockAddItem.mock.calls[1][0].text; - expect(message).toContain('\u001b[36mTool1\u001b[0m'); - expect(message).toContain('\u001b[36mTool2\u001b[0m'); + expect(message).toContain('Tool1'); + expect(message).toContain('Tool2'); expect(commandResult).toBe(true); }); @@ -664,9 +664,9 @@ Add any other context about the problem here. }); const message = mockAddItem.mock.calls[1][0].text; - expect(message).toContain('\u001b[36mTool1\u001b[0m'); + expect(message).toContain('Tool1'); expect(message).toContain('Description for Tool1'); - expect(message).toContain('\u001b[36mTool2\u001b[0m'); + expect(message).toContain('Tool2'); expect(message).toContain('Description for Tool2'); expect(commandResult).toBe(true); }); diff --git a/packages/cli/src/ui/hooks/slashCommandProcessor.ts b/packages/cli/src/ui/hooks/slashCommandProcessor.ts index dfefc562..11e1247f 100644 --- a/packages/cli/src/ui/hooks/slashCommandProcessor.ts +++ b/packages/cli/src/ui/hooks/slashCommandProcessor.ts @@ -473,25 +473,18 @@ export const useSlashCommandProcessor = ( geminiTools.forEach((tool) => { if (useShowDescriptions && tool.description) { // Format tool name in cyan using simple ANSI cyan color - message += ` - \u001b[36m${tool.displayName}\u001b[0m: `; + message += ` - \u001b[36m${tool.displayName} (${tool.name})\u001b[0m:\n`; // Apply green color to the description text const greenColor = '\u001b[32m'; const resetColor = '\u001b[0m'; // Handle multi-line descriptions by properly indenting and preserving formatting - const descLines = tool.description.split('\n'); - message += `${greenColor}${descLines[0]}${resetColor}\n`; + const descLines = tool.description.trim().split('\n'); // If there are multiple lines, add proper indentation for each line - if (descLines.length > 1) { - for (let i = 1; i < descLines.length; i++) { - // Skip empty lines at the end - if ( - i === descLines.length - 1 && - descLines[i].trim() === '' - ) - continue; + if (descLines) { + for (let i = 0; i < descLines.length; i++) { message += ` ${greenColor}${descLines[i]}${resetColor}\n`; } }