diff --git a/src/intro.ts b/src/intro.ts index 5a08117ab..dec4c2a12 100644 --- a/src/intro.ts +++ b/src/intro.ts @@ -39,7 +39,6 @@ export function introMessage(assistant: Assistant, mcpService: MCPService) { 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( diff --git a/src/slashCommands.ts b/src/slashCommands.ts index b9f04f4ce..c7d011f71 100644 --- a/src/slashCommands.ts +++ b/src/slashCommands.ts @@ -28,21 +28,11 @@ export function handleSlashCommands( "/login - Authenticate with your account", "/logout - Sign out of your current session", "/whoami - Check who you're currently logged in as", - "/models - List available AI models", ...(assistant.prompts?.map( (prompt) => `/${prompt?.name} - ${prompt?.description}` ) ?? []), ].join("\n"); return { output: helpMessage }; - case "models": - return { - output: `Available models:\n• ${ - assistant.models?.map((model) => model?.name)?.join("\n• ") || - "None" - }`, - }; - case "clear": - return { clear: true, output: "Chat history cleared." }; case "exit": return { exit: true, output: "Goodbye!" }; case "login": diff --git a/src/systemMessage.ts b/src/systemMessage.ts index ae13dda8a..bae4fa898 100644 --- a/src/systemMessage.ts +++ b/src/systemMessage.ts @@ -71,7 +71,7 @@ function getGitStatus(): string { const baseSystemMessage = `You are an agent in the Continue CLI. Given the user's prompt, you should use the tools available to you to answer the user's question. Notes: -1. IMPORTANT: You should be concise, direct, and to the point, since your responses will be displayed on a command line interface. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as "The answer is .", "Here is the content of the file..." or "Based on the information provided, the answer is..." or "Here is what I will do next...". +1. IMPORTANT: You should be concise, direct, and to the point, since your responses will be displayed on a command line interface. 2. When relevant, share file names and code snippets relevant to the query 3. Any file paths you return in your final response MUST be absolute. DO NOT use relative paths. Here is useful information about the environment you are running in: @@ -136,4 +136,4 @@ export function constructSystemMessage(rulesSystemMessage: string): string { } return systemMessage; -} \ No newline at end of file +} diff --git a/src/ui/SlashCommandUI.tsx b/src/ui/SlashCommandUI.tsx index 5cb26d433..60d454715 100644 --- a/src/ui/SlashCommandUI.tsx +++ b/src/ui/SlashCommandUI.tsx @@ -42,11 +42,6 @@ const SlashCommandUI: React.FC = ({ description: "Check who you're currently logged in as", category: "system", }, - { - name: "models", - description: "List available AI models", - category: "system", - }, ]; const assistantCommands: SlashCommand[] = diff --git a/src/ui/TUIChat.tsx b/src/ui/TUIChat.tsx index be3625c11..f05c4567a 100644 --- a/src/ui/TUIChat.tsx +++ b/src/ui/TUIChat.tsx @@ -1,6 +1,7 @@ import { ContinueClient } from "@continuedev/sdk"; import { Box, Text, useApp } from "ink"; import { ChatCompletionMessageParam } from "openai/resources.mjs"; +import path from "path"; import React, { useEffect, useState } from "react"; import { handleSlashCommands } from "../slashCommands.js"; import { StreamCallbacks, streamChatResponse } from "../streamChatResponse.js"; @@ -123,36 +124,19 @@ const TUIChat: React.FC = ({ // Create callbacks to handle streaming updates const streamCallbacks: StreamCallbacks = { onContent: (content: string) => { - setMessages((prev) => { - const newMessages = [...prev]; - - // Find or create current streaming message - if (!currentStreamingMessage) { - currentStreamingMessage = { role: "assistant", content: "", isStreaming: true }; - newMessages.push(currentStreamingMessage); - } - - // Update the streaming message - const streamingIndex = newMessages.indexOf(currentStreamingMessage); - if (streamingIndex >= 0) { - newMessages[streamingIndex].content += content; - } - - return newMessages; - }); + // Buffer content but don't update UI until complete or tool call + if (!currentStreamingMessage) { + currentStreamingMessage = { role: "assistant", content: "", isStreaming: true }; + } + currentStreamingMessage.content += content; }, onContentComplete: (content: string) => { - // Finalize the current streaming message + // Display the complete message if (currentStreamingMessage) { - setMessages((prev) => { - const newMessages = [...prev]; - const streamingIndex = newMessages.indexOf(currentStreamingMessage!); - if (streamingIndex >= 0) { - newMessages[streamingIndex].isStreaming = false; - newMessages[streamingIndex].content = content; - } - return newMessages; - }); + setMessages((prev) => [ + ...prev, + { role: "assistant", content: content, isStreaming: false } + ]); currentStreamingMessage = null; } }, @@ -163,9 +147,30 @@ const TUIChat: React.FC = ({ // Get the first parameter value for display const firstValue = Object.values(args)[0]; - return `${displayName}(${firstValue || ""})`; + + // Convert absolute paths to relative paths from workspace root + const formatPath = (value: any) => { + if (typeof value === "string" && path.isAbsolute(value)) { + const workspaceRoot = process.cwd(); + const relativePath = path.relative(workspaceRoot, value); + return relativePath || value; + } + return value; + }; + + return `${displayName}(${formatPath(firstValue) || ""})`; }; + // Display buffered content when tool starts + if (currentStreamingMessage && currentStreamingMessage.content) { + const messageContent = currentStreamingMessage.content; + setMessages((prev) => [ + ...prev, + { role: "assistant", content: messageContent, isStreaming: false } + ]); + currentStreamingMessage = null; + } + setMessages((prev) => [ ...prev, { @@ -218,15 +223,12 @@ const TUIChat: React.FC = ({ ); // Finalize any remaining streaming message - if (currentStreamingMessage) { - setMessages((prev) => { - const newMessages = [...prev]; - const streamingIndex = newMessages.indexOf(currentStreamingMessage!); - if (streamingIndex >= 0) { - newMessages[streamingIndex].isStreaming = false; - } - return newMessages; - }); + if (currentStreamingMessage && (currentStreamingMessage as any).content) { + const messageContent = (currentStreamingMessage as any).content; + setMessages((prev) => [ + ...prev, + { role: "assistant", content: messageContent, isStreaming: false } + ]); } } catch (error: any) { const errorMessage = `Error: ${error.message}`; diff --git a/src/ui/ToolResultSummary.tsx b/src/ui/ToolResultSummary.tsx index c360f9f0b..48fc5fd6a 100644 --- a/src/ui/ToolResultSummary.tsx +++ b/src/ui/ToolResultSummary.tsx @@ -1,4 +1,5 @@ import { Box, Text } from "ink"; +import path from "path"; import React from "react"; import { getToolDisplayName } from "../tools.js"; @@ -18,6 +19,16 @@ const ToolResultSummary: React.FC = ({ const chars = content.length; const displayName = toolName ? getToolDisplayName(toolName) : "Tool"; + // Convert absolute paths to relative paths from workspace root + const formatPath = (filePath: string) => { + if (path.isAbsolute(filePath)) { + const workspaceRoot = process.cwd(); + const relativePath = path.relative(workspaceRoot, filePath); + return relativePath || filePath; + } + return filePath; + }; + // Handle specific tool output formatting switch (toolName) { case "read_file": @@ -25,7 +36,7 @@ const ToolResultSummary: React.FC = ({ if (content.includes("→")) { const pathMatch = content.match(/^(.+?):/); const filePath = pathMatch ? pathMatch[1] : "file"; - return `${displayName} ${filePath} (${lines} lines)`; + return `${displayName} ${formatPath(filePath)} (${lines} lines)`; } return `${displayName} tool output (${lines} lines)`; diff --git a/src/ui/UserInput.tsx b/src/ui/UserInput.tsx index d05a4c54c..f4738e859 100644 --- a/src/ui/UserInput.tsx +++ b/src/ui/UserInput.tsx @@ -38,7 +38,6 @@ const UserInput: React.FC = ({ name: "whoami", description: "Check who you're currently logged in as", }, - { name: "models", description: "List available AI models" }, ]; const assistantCommands = diff --git a/test-relative-path.js b/test-relative-path.js new file mode 100644 index 000000000..89eb4975a --- /dev/null +++ b/test-relative-path.js @@ -0,0 +1,20 @@ +import path from "path"; + +// Test the relative path conversion logic +const formatPath = (value) => { + if (typeof value === "string" && path.isAbsolute(value)) { + const workspaceRoot = process.cwd(); + const relativePath = path.relative(workspaceRoot, value); + return relativePath || value; + } + return value; +}; + +// Test cases +console.log("Current working directory:", process.cwd()); +console.log("Test absolute path:", `/Users/nate/gh/continuedev/wt-no-abs/src/continueSDK.ts`); +console.log("Converted to relative:", formatPath(`/Users/nate/gh/continuedev/wt-no-abs/src/continueSDK.ts`)); +console.log("Test relative path:", `src/continueSDK.ts`); +console.log("Remains relative:", formatPath(`src/continueSDK.ts`)); +console.log("Test root file:", `/Users/nate/gh/continuedev/wt-no-abs/package.json`); +console.log("Converted to relative:", formatPath(`/Users/nate/gh/continuedev/wt-no-abs/package.json`)); \ No newline at end of file