diff --git a/src/intro.ts b/src/intro.ts index 74cda0e5f..5a08117ab 100644 --- a/src/intro.ts +++ b/src/intro.ts @@ -21,10 +21,10 @@ export function introMessage(assistant: Assistant, mcpService: MCPService) { console.info(chalk.cyan(CONTINUE_ASCII_ART)); - console.info(`\n${chalk.bold.blue(`Assistant: ${assistantConfig.name}`)}`); - console.info(`${chalk.blue(`Model: ${assistant.getModel()}`)}\n`); + console.info(`\n${chalk.bold.blue(`Agent: ${assistantConfig.name}\n`)}`); + console.info(`${chalk.yellow("Model:")} ${assistant.getModel()}\n`); - console.info(chalk.yellow("Available tools:")); + console.info(chalk.yellow("Tools:")); getAllTools().forEach((tool) => { console.info( `- ${chalk.green(tool.function.name)}: ${tool.function.description ?? ""}` @@ -35,14 +35,16 @@ export function introMessage(assistant: Assistant, mcpService: MCPService) { }); console.info(""); - console.info(chalk.yellow("\nAvailable slash commands:")); - console.info("- /exit: Exit the chat"); - console.info("- /clear: Clear the chat history"); - console.info("- /help: Show help message"); - console.info("- /models: Show available models"); - console.info("- /login: Authenticate with your account"); - console.info("- /logout: Sign out of your current session"); - console.info("- /whoami: Check who you're currently logged in as"); + console.info(chalk.yellow("Slash commands:")); + console.info(`- ${chalk.green("/exit")}: Exit the chat`); + console.info(`- ${chalk.green("/clear")}: Clear the chat history`); + console.info(`- ${chalk.green("/help")}: Show help message`); + console.info(`- ${chalk.green("/models")}: Show available models`); + console.info(`- ${chalk.green("/login")}: Authenticate with your account`); + console.info(`- ${chalk.green("/logout")}: Sign out of your current session`); + console.info( + `- ${chalk.green("/whoami")}: Check who you're currently logged in as` + ); for (const prompt of assistantConfig.prompts ?? []) { console.info(`- /${prompt?.name}: ${prompt?.description}`); } diff --git a/src/tools.ts b/src/tools.ts index a9b7a7b5e..f2aeb341e 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -3,6 +3,7 @@ import { executeToolCall, extractToolCalls, getToolsDescription, + getToolDisplayName, Tool, } from "./tools/index.js"; @@ -11,6 +12,7 @@ export { executeToolCall, extractToolCalls, getToolsDescription, + getToolDisplayName, Tool, BUILTIN_TOOLS as tools, }; diff --git a/src/tools/exit.ts b/src/tools/exit.ts index 5f884a919..999600d6a 100644 --- a/src/tools/exit.ts +++ b/src/tools/exit.ts @@ -2,6 +2,7 @@ import { Tool } from "./types.js"; export const exitTool: Tool = { name: "exit", + displayName: "Exit", description: "Exit the current process with status code 1, indicating a failure or error", parameters: {}, diff --git a/src/tools/index.ts b/src/tools/index.ts index 3ee6972c2..2340b6db3 100644 --- a/src/tools/index.ts +++ b/src/tools/index.ts @@ -22,6 +22,11 @@ export const BUILTIN_TOOLS: Tool[] = [ ...(parseArgs().isHeadless ? [exitTool] : []), ]; +export function getToolDisplayName(toolName: string): string { + const tool = BUILTIN_TOOLS.find(t => t.name === toolName); + return tool?.displayName || toolName; +} + export function getToolsDescription(): string { return BUILTIN_TOOLS.map((tool) => { const params = Object.entries(tool.parameters) @@ -99,6 +104,7 @@ export async function executeToolCall(toolCall: { ?.getTools() .map((t) => ({ name: t.name, + displayName: t.name.replace("mcp__", "").replace("ide__", ""), description: t.description ?? "", parameters: convertInputSchemaToParameters(t.inputSchema), run: async (args: any) => { diff --git a/src/tools/listFiles.ts b/src/tools/listFiles.ts index bcd6df4d2..80010e58d 100644 --- a/src/tools/listFiles.ts +++ b/src/tools/listFiles.ts @@ -5,6 +5,7 @@ import { Tool } from "./types.js"; // List files in a directory export const listFilesTool: Tool = { name: "list_files", + displayName: "List", description: "List files in a directory", parameters: { dirpath: { diff --git a/src/tools/readFile.ts b/src/tools/readFile.ts index 2ea6bf5de..45ed8aa5b 100644 --- a/src/tools/readFile.ts +++ b/src/tools/readFile.ts @@ -3,6 +3,7 @@ import { Tool } from "./types.js"; export const readFileTool: Tool = { name: "read_file", + displayName: "Read", description: "Read the contents of a file at the specified path", parameters: { filepath: { diff --git a/src/tools/runTerminalCommand.ts b/src/tools/runTerminalCommand.ts index 176f669e8..e753e8a31 100644 --- a/src/tools/runTerminalCommand.ts +++ b/src/tools/runTerminalCommand.ts @@ -3,6 +3,7 @@ import { exec } from "child_process"; export const runTerminalCommandTool: Tool = { name: "run_terminal_command", + displayName: "Terminal", description: "Executes a terminal command and returns the output.", parameters: { command: { diff --git a/src/tools/searchCode.ts b/src/tools/searchCode.ts index 1b53b0c3f..fe6073203 100644 --- a/src/tools/searchCode.ts +++ b/src/tools/searchCode.ts @@ -7,6 +7,7 @@ const execPromise = util.promisify(child_process.exec); export const searchCodeTool: Tool = { name: "search_code", + displayName: "Search", description: "Search the codebase using ripgrep (rg) for a specific pattern", parameters: { pattern: { diff --git a/src/tools/types.ts b/src/tools/types.ts index 45ca005a3..86074f13b 100644 --- a/src/tools/types.ts +++ b/src/tools/types.ts @@ -9,6 +9,7 @@ export type ToolParameters = Record< export interface Tool { name: string; + displayName: string; description: string; parameters: ToolParameters; run: (args: any) => Promise; diff --git a/src/tools/viewDiff.ts b/src/tools/viewDiff.ts index b16eb861b..ebc9abab2 100644 --- a/src/tools/viewDiff.ts +++ b/src/tools/viewDiff.ts @@ -7,6 +7,7 @@ const execPromise = util.promisify(child_process.exec); export const viewDiffTool: Tool = { name: "view_diff", + displayName: "Diff", description: "View all uncommitted changes in the git repository", parameters: { path: { diff --git a/src/tools/writeFile.ts b/src/tools/writeFile.ts index 54c1bc221..2ab64799f 100644 --- a/src/tools/writeFile.ts +++ b/src/tools/writeFile.ts @@ -4,6 +4,7 @@ import { Tool } from "./types.js"; export const writeFileTool: Tool = { name: "write_file", + displayName: "Write", description: "Write content to a file at the specified path", parameters: { filepath: { diff --git a/src/ui/TUIChat.tsx b/src/ui/TUIChat.tsx index 90e753e13..f6a0a19df 100644 --- a/src/ui/TUIChat.tsx +++ b/src/ui/TUIChat.tsx @@ -4,6 +4,7 @@ import { ChatCompletionMessageParam } from "openai/resources.mjs"; import React, { useEffect, useState } from "react"; import { handleSlashCommands } from "../slashCommands.js"; import { StreamCallbacks, streamChatResponse } from "../streamChatResponse.js"; +import { getToolDisplayName } from "../tools.js"; import ToolResultSummary from "./ToolResultSummary.js"; import UserInput from "./UserInput.js"; @@ -119,35 +120,12 @@ const TUIChat: React.FC = ({ }, onToolStart: (toolName: string, toolArgs?: any) => { const formatToolCall = (name: string, args: any) => { - if (!args) return name; + const displayName = getToolDisplayName(name); + if (!args) return displayName; - switch (name) { - // CLI Internal Tools (snake_case) - case "read_file": - return `Read(${args.filepath || ""})`; - case "write_file": - return `Write(${args.filepath || ""})`; - case "list_files": - return `List(${args.dirpath || ""})`; - case "search_code": - return `Search(${args.pattern || ""})`; - case "run_terminal_command": - return `Terminal(${args.command || ""})`; - case "view_diff": - return `Diff(${args.path || "."})`; - default: - // Handle MCP tools or unknown tools - if (name.startsWith("mcp__")) { - const mcpToolName = name - .replace("mcp__", "") - .replace("ide__", ""); - const firstParam = Object.values(args)[0]; - return `${mcpToolName}(${firstParam || ""})`; - } - // For unknown tools, show first parameter value - const firstValue = Object.values(args)[0]; - return `${name}(${firstValue || ""})`; - } + // Get the first parameter value for display + const firstValue = Object.values(args)[0]; + return `${displayName}(${firstValue || ""})`; }; setMessages((prev) => [ diff --git a/src/ui/ToolResultSummary.tsx b/src/ui/ToolResultSummary.tsx index 0605d1144..c360f9f0b 100644 --- a/src/ui/ToolResultSummary.tsx +++ b/src/ui/ToolResultSummary.tsx @@ -1,5 +1,6 @@ import { Box, Text } from "ink"; import React from "react"; +import { getToolDisplayName } from "../tools.js"; interface ToolResultSummaryProps { toolName?: string; @@ -15,18 +16,18 @@ const ToolResultSummary: React.FC = ({ const lines = content.split("\n").length; const chars = content.length; + const displayName = toolName ? getToolDisplayName(toolName) : "Tool"; - // Use exact tool name matching + // Handle specific tool output formatting switch (toolName) { - // CLI Internal Tools (snake_case) case "read_file": // Try to extract file path from content if it contains line numbers if (content.includes("→")) { const pathMatch = content.match(/^(.+?):/); const filePath = pathMatch ? pathMatch[1] : "file"; - return `Read ${filePath} (${lines} lines)`; + return `${displayName} ${filePath} (${lines} lines)`; } - return `Read tool output (${lines} lines)`; + return `${displayName} tool output (${lines} lines)`; case "write_file": return "File written successfully"; @@ -44,21 +45,11 @@ const ToolResultSummary: React.FC = ({ return `Diff output (${lines} lines)`; default: - // Handle MCP tools or unknown tools - if (toolName?.startsWith("mcp__")) { - const mcpToolName = toolName - .replace("mcp__", "") - .replace("ide__", ""); - return `${mcpToolName} tool output (${lines} lines)`; - } - - // Fallback for unknown tools + // Fallback for all tools using display name if (chars > 1000) { - return `${ - toolName || "Tool" - } output: ${lines} lines, ${chars} characters`; + return `${displayName} output: ${lines} lines, ${chars} characters`; } else if (lines > 10) { - return `${toolName || "Tool"} output: ${lines} lines`; + return `${displayName} output: ${lines} lines`; } else { return content.slice(0, 100) + (content.length > 100 ? "..." : ""); }